上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 38 下一页
摘要: 1 class Solution 2 { 3 public: 4 vector<int> productExceptSelf(vector<int>& nums) 5 { 6 int n = nums.size(); 7 vector<int> A(n,1),B(n,1); 8 vector<int 阅读全文
posted @ 2020-04-12 18:36 Jinxiaobo0509 阅读(149) 评论(0) 推荐(0)
摘要: 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), 阅读全文
posted @ 2020-04-12 18:02 Jinxiaobo0509 阅读(128) 评论(0) 推荐(0)
摘要: 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 * }; 阅读全文
posted @ 2020-04-12 17:44 Jinxiaobo0509 阅读(105) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 bool isPowerOfTwo(int n) 5 { 6 return n > 0 && (n & n - 1) == 0; 7 } 8 }; 1 class Solution 2 { 3 public: 4 bool isPow 阅读全文
posted @ 2020-04-12 16:04 Jinxiaobo0509 阅读(122) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 int kthSmallest(TreeNode* root, int k) 5 { 6 stack<TreeNode*> s; 7 TreeNode *cur = root; 8 while(!s.empty() || cur) 9 阅读全文
posted @ 2020-04-12 13:58 Jinxiaobo0509 阅读(183) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 vector<int> majorityElement(vector<int>& nums) 5 { 6 vector<int> res; 7 if (nums.empty()) return res; 8 // 初始化两个候选人ca 阅读全文
posted @ 2020-04-12 13:31 Jinxiaobo0509 阅读(140) 评论(0) 推荐(0)
摘要: 1 //简单题 2 class Solution 3 { 4 public: 5 vector<string> summaryRanges(vector<int>& nums) 6 { 7 vector<string> res; 8 if(nums.empty()) return res; 9 ve 阅读全文
posted @ 2020-04-12 11:59 Jinxiaobo0509 阅读(155) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 int calculate(string s) 5 { 6 s += "+";//1、最后一位加一个"+" 7 if (s.empty()) return 0; 8 stack<int> vals; 9 stack<char> ops 阅读全文
posted @ 2020-04-12 11:35 Jinxiaobo0509 阅读(131) 评论(0) 推荐(0)
摘要: 1 class MyQueue 2 { 3 stack<int> s1,s2; 4 public: 5 MyQueue() {} 6 7 void push(int x) 8 { 9 s1.push(x); 10 } 11 12 int pop() 13 { 14 while(!s1.empty() 阅读全文
posted @ 2020-04-11 23:17 Jinxiaobo0509 阅读(116) 评论(0) 推荐(0)
摘要: 1 class MyStack 2 { 3 queue<int> q1;//数据队列 4 queue<int> q2;//临时队列 5 public: 6 MyStack() {} 7 8 void push(int x) 9 { 10 q1.push(x); 11 } 12 13 int pop( 阅读全文
posted @ 2020-04-11 22:36 Jinxiaobo0509 阅读(93) 评论(0) 推荐(0)
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 38 下一页