摘要:
vector generateParenthesis(int n) { // Note: The Solution object is instantiated only once and is reused by each test case. int left_cnt = n,right_cnt = n; vector res; dfs(left_cnt,right_cnt,"",res); return res; } void dfs(int left_cnt,int right_cnt,s... 阅读全文
摘要:
ListNode *removeNthFromEnd(ListNode *head, int n) { // Note: The Solution object is instantiated only once and is reused by each test case. if(!head||nnext; while(fast->next) { fast = fast->next; prev = slow; slow = slow->next; ... 阅读全文
摘要:
int uniquePathsWithObstacles(vector > &obstacleGrid) { // Start typing your C/C++ solution below // DO NOT write int main() function if(obstacleGrid[0][0]==1) return 0; int m = obstacleGrid.size(); int n = obstacleGrid[0].size(); vector> dp(m,... 阅读全文
摘要:
bool isPalindrome(int x) { // Note: The Solution object is instantiated only once and is reused by each test case. if(x=10) { div*=10; } while(x) { int a = x/div; int b = x%10; if(a!=b) re... 阅读全文
摘要:
考虑越界的问题 int reverse(int x) { // Note: The Solution object is instantiated only once and is reused by each test case. bool bNega = false; if(xINT_MAX) return (bNega?INT_MIN:INT_MAX); else return (bNega?-res:res); } 阅读全文