
二分法binary search
老晨磕技术
每天定时定量,持之以恒。一天一点数十年持续积累,坚持的人总不会混得太差。
展开
-
晨哥Leetcode 644. Maximum Average Subarray II
Given an array consisting of n integers, find the contiguous subarray whose length is greater than or equal to k that has the maximum average value. And you need to output the maximum average value.E...原创 2019-09-01 09:15:27 · 272 阅读 · 0 评论 -
晨哥Leetcode 528. Random Pick with Weight
Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proportion to its weight.Note:1 <= w.length <= 1...原创 2019-09-10 10:03:31 · 146 阅读 · 0 评论 -
晨哥Leetcode 497. Random Point in Non-overlapping Rectangles
Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the space covered by the rectangles.Note:An integer poin...原创 2019-09-11 07:29:20 · 232 阅读 · 0 评论 -
晨哥Leetcode 315. Count of Smaller Numbers After Self--binary search一次bug free写好秘诀
给定一个整数数组nums,返回一个新的counts数组。counts[i]表示:nums[i]右侧比它小的数的个数。比较好的算是是用Binary Indexed Tree, 不过我觉得掌握普通的binary search已经勉强够用了,不追求高难度的话就把下面的普通解法扎实写好就行binary search一次bug free写好秘诀:把一些常见case代进去试试:+当前list为空的情...原创 2019-09-14 04:21:32 · 129 阅读 · 0 评论 -
老晨Leetcode 1055. Shortest Way to Form String (Java)
From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions).Given two strings source and target, return the minimum number of subsequences...原创 2019-09-16 11:24:33 · 2679 阅读 · 0 评论