随笔分类 - LeetCode题解
摘要:1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
阅读全文
摘要:1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
阅读全文
摘要:1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
阅读全文
摘要:1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
阅读全文
摘要:1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
阅读全文
摘要:1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
阅读全文
摘要:1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
阅读全文
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * };
阅读全文
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * };
阅读全文
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * };
阅读全文
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * };
阅读全文
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * };
阅读全文
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * };
阅读全文
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * };
阅读全文
摘要:1 class Solution 2 { 3 public: 4 int hIndex(vector<int>& nums) 5 { 6 int l = 0,r = nums.size(); 7 while(l < r) 8 { 9 int mid = l + r + 1 >> 1; 10 11 /
阅读全文
摘要:1 class Solution 2 { 3 public: 4 int findPeakElement(vector<int>& nums) 5 { 6 int l = 0,r = nums.size() - 1; 7 while(l < r) 8 { 9 int mid = l + r >> 1
阅读全文
摘要:1 // Forward declaration of isBadVersion API. 2 bool isBadVersion(int version); 3 4 class Solution 5 { 6 public: 7 int firstBadVersion(int n) 8 { 9 in
阅读全文
摘要:1 //利用模板 2 3 //以最后一个值来划分 4 //如果比它小,在右边,更新r 5 //反之,更新l 6 class Solution 7 { 8 public: 9 int findMin(vector<int>& nums) 10 { 11 int l = 0,r = nums.size(
阅读全文
摘要:1 class Solution 2 { 3 public: 4 bool searchMatrix(vector<vector<int>>& matrix, int target) 5 { 6 if(matrix.empty() || matrix[0].empty()) return false
阅读全文
摘要:1 使用数组中的值作为索引下标进行遍历,遍历的结果肯定是一个环(有一个重复元素) 2 检测重复元素问题转换成检测环的入口 3 为了找到环的入口,可以进行如下步骤: 4 5 设置两个快慢指针, fast每次走两步,slow每次走一步,最终走了slow走了n步与fast相遇,fast走了2*n,fast
阅读全文

浙公网安备 33010602011771号