- 博客(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
857
原创 二叉树的各种递归和栈的遍历。
#include #include #include using 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
1000
原创 Value Palindrome
运用了STL函数。#include #include using 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
815
原创 二叉树的先序遍历
二叉树的先序遍历。 递归和迭代两种方法,感觉写迭代的是时候好多废话,懒得改了。停几天再改#include #include #include using 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
938
原创 一些BST基础知识
又看了一遍BST,把这些基础写了下来。分享一下。代码测试通过。#include #include #include using 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
971
原创 [leetcode]SameTree
Same Tree Given 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
900
原创 [LeetCode]3sum
#include #include #include using 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
1014
原创 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
821
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅