LeetCode
LeetCode copied to clipboard
This repository contains the solutions and explanations to the algorithm problems on LeetCode. Only medium or above are included. All are written in C++/Python and implemented by myself. The problems...
I just create a java version
DD
Hello Sir,hope you are doing great. The Code for 1569 LC seems to be overly exaggerated and long. Hence, I wanted to contribute a version2 for the 1569, which is...
位置:maxSubArrSum函数的第37行。 原因:代码里对max_ending_here先做取模运算,再与max_so_far比较,但比较运算应放在取模运算之前。比如 1 % 4 > 4 % 4,但实际上1 < 4。 改正:删掉第34行,并将第23行的`maxSubArrSum(arr)`改成`maxSubArrSum(arr)%M`。
这道题的follow up是能不能做到线性时间和常数空间,不知道老师能否更新一下quick select的做法。 根据题目要求被夹在中间的数是不能等于两边的数的,现在有点困惑在快排结束之后怎么swap了
这里为什么不用abs(x - nums[mid]) 和 abs(x - nums[mid + k]), 而是选择用 x - nums[mid] 和 nums[mid + k] - k。 虽然说对于x 在递增数组范围外的情况是可以给到正确答案的,但是有点counter intuitive。希望能有解释。
I will add screenshot of leet code saying and show how it has been calculated in a descriptive manner I will like to work on it
Fix typo: s.mgth() -> s.size() in 3234.Count-the-Number-of-Substrings-With-Dominant-Ones Also, we don't need max() on line 24: ```cpp ret += extra+1; ``` because the if statement: ```cpp if (right[j-1] + have >=...