上一页 1 2 3 4 5 6 7 8 9 10 ··· 38 下一页
摘要: 题目: 解答: 方法一:C++超时 1 class MedianFinder { 2 vector<double> store; 3 4 public: 5 // Adds a number into the data structure. 6 void addNum(int num) 7 { 8 阅读全文
posted @ 2020-05-09 16:35 梦醒潇湘 阅读(180) 评论(0) 推荐(0)
摘要: 题目: 解答: 1 class Solution { 2 public: 3 vector<int> getLeastNumbers(vector<int>& arr, int k) 4 { 5 vector<int> res; 6 priority_queue<int> q; 7 for (int 阅读全文
posted @ 2020-05-09 16:26 梦醒潇湘 阅读(152) 评论(0) 推荐(0)
摘要: 题目: 解答: 1 class Solution { 2 public: 3 int majorityElement(vector<int>& nums) 4 { 5 int x = 0; 6 int votes = 0; 7 for(int num : nums) 8 { 9 if(votes = 阅读全文
posted @ 2020-05-09 16:23 梦醒潇湘 阅读(127) 评论(0) 推荐(0)
摘要: 题目: 解答: 1 class Solution { 2 public: 3 vector<string> permutation(string str) 4 { 5 vector<string> result; 6 if(str.empty()) 7 { 8 return result; 9 } 阅读全文
posted @ 2020-05-09 16:18 梦醒潇湘 阅读(175) 评论(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) : 阅读全文
posted @ 2020-05-09 16:11 梦醒潇湘 阅读(99) 评论(0) 推荐(0)
摘要: 题目: 解答: 1 // 中序遍历即可。只需要记录一个pre指针即可。 2 3 4 class Solution { 5 public: 6 TreeNode* Convert(TreeNode* pRootOfTree) 7 { 8 if(pRootOfTree == nullptr) 9 { 1 阅读全文
posted @ 2020-05-09 16:05 梦醒潇湘 阅读(136) 评论(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) : 阅读全文
posted @ 2020-05-09 16:01 梦醒潇湘 阅读(223) 评论(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) : 阅读全文
posted @ 2020-05-09 15:59 梦醒潇湘 阅读(148) 评论(0) 推荐(0)
摘要: 题目: 解答: BST的后序序列的合法序列是,对于一个序列S,最后一个元素是x (也就是根),如果去掉最后一个元素的序列为T,那么T满足:T可以分成两段,前一段(左子树)小于x,后一段(右子树)大于x,且这两段(子树)都是合法的后序序列。 1 class Solution { 2 public: 3 阅读全文
posted @ 2020-05-09 15:54 梦醒潇湘 阅读(169) 评论(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) : 阅读全文
posted @ 2020-05-09 15:41 梦醒潇湘 阅读(136) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 38 下一页