У нас вы можете посмотреть бесплатно Random Pick with Weight | Bucket approach | Leetcode или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
This video explains a very tricky and important interview question which is to randomly pick index based on weighted value.In this problem, we are provided with an array of weights and we are required to choose an index in such a way that the probability of getting an index chosen is higher for a higher weight index and lower for a lower weight index.I have explained the approach to solve this problem using bucket.Once we form buckets then the next step is to just generate the random number for each query in the range of 0 to SUM and use binary search to find in which bucket does the random number fall into.We can also use upper_bound to avoid implementing binary search.I have explained the code walkthrough at the end.CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :) ================================================================= INSTAGRAM: / surya.pratap.k LinkedIn: / surya-pratap-kahar-47bb01168 ================================================================= CODE LINK: https://gist.github.com/SuryaPratapK/... SIMILAR PROBLEM:- Aggressive cow: • Aggressive cow | SPOJ