- 博客(4)
- 资源 (4)
- 问答 (1)
- 收藏
- 关注
原创 Find the Difference
https://leetcode.com/problems/find-the-difference/思路:把字符串s存到hash表中,相同字母累加; 遍历字符串t,字符对应hash表的字符个数则减一,如果小于0则返回得到结果 class Solution { public: char findTheDifference(string s, string t) { map<ch
2016-10-03 11:49:04 381
原创 Sum of Left Leaves
https://leetcode.com/problems/sum-of-left-leaves/思路:递归求解,给一个标记,向左子树遍历则为true /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;
2016-10-03 00:56:05 416
原创 二叉树先序遍历中序遍历递归及非递归解法
Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. 先序遍历非递归: /** * Definition for a
2016-10-02 23:14:03 427
原创 two-sum
根据找出数组中两个数相加等于target,返回数组对应的下标。class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { int len = nums.size(); map<int,int> mp; for(int i = 0;i < len;i++
2016-10-01 15:47:10 302
关于string和char的程序,求解~?为什么运行不通过
2015-01-12
TA创建的收藏夹 TA关注的收藏夹
TA关注的人