- 浏览: 407434 次
- 性别:
- 来自: 北京
最新评论
-
ahead_zhan:
good good good
flex3控件_ModuleLoader -
lonerzf:
好样的。非常感谢楼主
OpenCV视频教程整理 -
lonerzf:
好样的。谢谢~
OpenCV视频教程整理 -
coding1688:
博主说的不错,我在实现瀑布流布局时也用的masonry插件,有 ...
Javascript 瀑布流式布局及其动态效果的实现 -
snowolf:
除非玩游戏,不然没啥win的事情,或者用win的银行客户端,通 ...
macbook安装操作系统的机理分析
文章列表
参考:http://pthread.blog.163.com/blog/static/169308178201210112045787/
Most textbooks mention that binary tree can be traversed using recursion or , using stack without recursion. The recursive procedure is simple to write, and the stack version use extra space.
There's also a very well designe ...
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
if(!head) return NULL;
if(!head->ne ...
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
if(!head) return NULL;
if(!head->nex ...
Question:
input : n
output: A random permutation of [0 .. n-1]
ie:
input: 5
output: 0 3 2 4 1
// Type your C++ code and click the "Run Code" button!
// Your code output will be shown on the left.
// Click on the "Show input" button to enter input ...
Rotate List (C++)
- 博客分类:
- 算法设计
Question:
Given a list, rotate the list to the right by k places, where k is non-negative.
For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.
/**
* Definition for singly-linked list.
* struct ListNode {
*
question:
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.
class Solution {
public:
i ...
class Solution {
public:
int longestConsecutive(vector<int> &num) {
int n = num.size();
if(n <= 0) return 0;
if(n == 1) return 1;
sort(num.begin(), num.end());
int maxAll = 1;
int maxLast = 1;
...
#define TEMP_FLAG 'Z'
#define O_FLAG 'O'
#define X_FLAG 'X'
class Solution {
public:
void solve(vector<vector<char>> &board) {
int m = board.size();
if(m <= 0) return;
// deal with the border element
for(int i = 0; ...
Sum Root to Leaf Numbers
- 博客分类:
- 算法设计
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int sumNumbers(TreeNode *root) {
vector<vector<int>&g ...
Path Sum I (C++)
- 博客分类:
- 算法设计
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
bool hasPathSum(TreeNode *root, int sum) {
if(!root) return fa ...
Path Sum II (C++)
- 博客分类:
- 算法设计
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<vector<int> > pathSum(TreeNode *root, int sum) {
...
单链表翻转(C++ 实现)
- 博客分类:
- 算法设计
// Type your C++ code and click the "Run Code" button!
// Your code output will be shown on the left.
// Click on the "Show input" button to enter input data to be read (from stdin).
#include <iostream>
using namespace std;
struct ListNode {
int val;
Lis ...
二叉树中寻找节点和最大值的路径(C++ 实现)
- 博客分类:
- 算法设计
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
// rule in result vector during iteration:
// single path: 0; ----> v0
// cross path: 1; ...
整数翻转(C++实现)
- 博客分类:
- 算法设计
// Type your C++ code and click the "Run Code" button!
// Your code output will be shown on the left.
// Click on the "Show input" button to enter input data to be read (from stdin).
#include <iostream>
using namespace std;
class Solution {
public:
int rever ...
图克隆(C++实现)
- 博客分类:
- 算法设计
// Type your C++ code and click the "Run Code" button!
// Your code output will be shown on the left.
// Click on the "Show input" button to enter input data to be read (from stdin).
#include <iostream>
using namespace std;
typedef struct GNode {
int val;
...