Consider a matrix M with dimensions width * height, such that every cell has value 0 or 1, and any s ...
Consider a matrix M with dimensions width * height, such that every cell has value 0 or 1, and any s ...
Greedy Use two pointers, one for source: i, one for target: j. While j scan through target, ...
原题链接在这里:https://leetcode.com/problems/shortest-way-to-form-string/ 题目: From any string, we can for ...
refer to Recursion https://leetcode.com/discuss/84702/share-my-solution and Iteration https: ...
原题链接在这里:https://leetcode.com/problems/minimum-cost-to-connect-sticks/ 题目: You have some sticks wit ...
直接根据最短distance greedy做。 用了优先队列,C++ less<type> 是大的先,所以我们可以重载<符号,把逻辑反过来。 第二种写法不用结 ...
原题链接在这里:https://leetcode.com/problems/campus-bikes/ 题目: On a campus represented as a 2D grid, ther ...
We can use greedy method to solve this. num1 can take charge of i(0<=i<=k) numbers and ...
Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings o ...
Given a list of Connections, which is the Connection class (the city name at both ends of the ...