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 ...