摘要:
The trick is, we can work on a reversed vector - learnt from EPI.class Solution {public: vector plusOne(vector &digits) { std::reverse(digit... 阅读全文
摘要:
My first reaction: move all A elements back by n positions, and start everything from A[0] and B[0]. But a smarter idea is to start everything from th... 阅读全文
摘要:
Classic recursion\pruning problem. We can use O(n) space: A[i] = j means [i,j] is occupied.class Solution {public: int ret; bool isValid(int *A,... 阅读全文
摘要:
Apparently BFS is the most obvious one.. but it is not that simple - only constant extra space is provided.Then the only strategy to take is recursion... 阅读全文
摘要:
Very classic problem. You can brush up your DP and Searching skills.DP:class Solution {public: int maxSubArray(int A[], int n) { // dp[i + 1... 阅读全文