会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
QingLiXueShi
培养勇气,培养爱好,培养习惯。
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
下一页
2015年7月10日
【LeetCode 1_数组_哈希表】Two Sum
摘要: 解法一:O(N) 1 vector twoSum(vector& nums, int target) 2 { 3 unordered_map numsHash; 4 vector res; 5 6 for (int i = 0; i twoSum(vector& nums...
阅读全文
posted @ 2015-07-10 15:20 QingLiXueShi
阅读(162)
评论(0)
推荐(0)
2015年7月9日
【LeetCode 222_完全二叉树_遍历】Count Complete Tree Nodes
摘要: 解法一:递归int countNodes(TreeNode* root){ if (root == NULL) return 0; TreeNode *pLeft = root->left; TreeNode *pRight = root->right; ...
阅读全文
posted @ 2015-07-09 17:14 QingLiXueShi
阅读(458)
评论(0)
推荐(0)
【LeetCode 144_二叉树_遍历】Binary Tree Preorder Traversal
摘要: 解法一:非递归 1 vector preorderTraversal(TreeNode* root) 2 { 3 vector res; 4 if (root == NULL) 5 return res; 6 7 stack node_stack; 8 ...
阅读全文
posted @ 2015-07-09 11:07 QingLiXueShi
阅读(194)
评论(0)
推荐(0)
二叉树的遍历
摘要: 1 struct TreeNode { 2 char val; 3 TreeNode *left; 4 TreeNode *right; 5 int visitCount; //节点访问次数,后序遍历会用到 6 TreeNode(c...
阅读全文
posted @ 2015-07-09 10:46 QingLiXueShi
阅读(170)
评论(0)
推荐(0)
2015年7月8日
【LeetCode 36_哈希表】Valid Sudoku
摘要: 1 //occupyed_1检查行是否占用 2 //occupyed_2检查列是否占用 3 //occupyed_3检查块是否占用 4 bool isValidSudoku(vector>& board) 5 { 6 int occupyed_1[9][9], occupyed_2[9][...
阅读全文
posted @ 2015-07-08 21:33 QingLiXueShi
阅读(160)
评论(0)
推荐(0)
【LeetCode 8_字符串_实现】String to Integer (atoi)
摘要: 1 enum status{VALID = 0, INVALID}; 2 int g_status; 3 4 long long SubStrToInt(const char* str, bool minus) 5 { 6 long long num = 0; 7 int fl...
阅读全文
posted @ 2015-07-08 16:48 QingLiXueShi
阅读(195)
评论(0)
推荐(0)
【LeetCode 232_数据结构_队列_实现】Implement Queue using Stacks
摘要: 1 class Queue { 2 public: 3 // Push element x to the back of queue. 4 void push(int x) { 5 while (!nums.empty()) { 6 nums...
阅读全文
posted @ 2015-07-08 14:38 QingLiXueShi
阅读(127)
评论(0)
推荐(0)
【LeetCode 225_数据结构_栈_实现】Implement Stack using Queues
摘要: 1 class Stack { 2 public: 3 // Push element x onto stack. 4 void push(int x) { 5 int len = nums.size(); 6 nums.push(x); 7 ...
阅读全文
posted @ 2015-07-08 11:29 QingLiXueShi
阅读(140)
评论(0)
推荐(0)
2015年7月7日
【LeetCode 38_字符串_算术运算】Count and Say
摘要: 1 string countAndSay(int n) 2 { 3 string res; 4 if (n 1) { 9 int len = res.size();10 int i, j;11 string resTmp;12 13...
阅读全文
posted @ 2015-07-07 20:08 QingLiXueShi
阅读(271)
评论(0)
推荐(0)
最大子数组和问题的解
摘要: 寻找数组A的和最大的非空连续子数组。例如:A[] = {1, -2, 3, 10, -4, 7, 2, -5}的最大子数组为3, 10, -4, 7, 2,其最大和为18。数组元素都为负时,返回最大负值。解法一:暴力枚举,O(N^2) 1 //left,最大子数组左端 2 //right,最大子数组...
阅读全文
posted @ 2015-07-07 18:30 QingLiXueShi
阅读(283)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
下一页
公告