- 博客(8)
- 收藏
- 关注
原创 [leetcode]twoSum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe
2013-12-21 21:24:58
823
原创 二叉树的各种递归和栈的遍历。
#include#include#includeusing namespace std;struct node{ int data; node*left; node*right; node(int x) :data(x), left(nullptr), right(nullptr){}};//新建节点node*newNode(int elem){ node*cur = n
2013-12-18 00:05:14
969
原创 Value Palindrome
运用了STL函数。#include#includeusing namespace std;bool isPalindrome1(string text){ text.erase(remove_if(text.begin(), text.end(), [](char c){ //lambda return !isalpha(c) ; }), text.end());
2013-12-11 10:14:51
783
原创 二叉树的先序遍历
二叉树的先序遍历。递归和迭代两种方法,感觉写迭代的是时候好多废话,懒得改了。停几天再改#include#include#includeusing namespace std;struct node{ int data; node*left; node*right; node(int x) :data(x), left(nullptr), right(nullptr){}};
2013-12-10 21:43:32
906
原创 一些BST基础知识
又看了一遍BST,把这些基础写了下来。分享一下。代码测试通过。#include#include#includeusing namespace std;struct TreeNode{ int val; TreeNode*left; TreeNode*right; TreeNode(int x) :val(x), left(NULL), right(NULL){}};TreeNo
2013-12-10 19:50:17
936
原创 [leetcode]SameTree
Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the
2013-12-10 10:52:34
861
原创 [LeetCode]3sum
#include#include#includeusing namespace std;class solution{public:vector > threesum(vector& num){vector > result;if(num.size() sort(num.begin(),num.end());const int target=0;
2013-11-03 19:46:24
990
原创 leetcode(longest consecutive sequence)
Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest
2013-11-03 19:16:56
787
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人