- 博客(6)
- 收藏
- 关注
原创 字符串翻转问题
给定一个字符串,实现字符串翻转,要求空间复杂度为O(1),时间复杂度为O(n)==============================================可以采用与快速排序的思想类似,通过备份一个值不断挖洞来实现翻转char *from, *to;while (from < to) { char t = s[from]; s[from++] = s[to];
2017-03-16 18:03:47 349
原创 binary-tree-preorder-traversal
Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3]. Note: Recursive solution is trivial,
2017-03-07 22:35:49 273
原创 maximum-depth-of-binary-tree
题目描述Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.解题思路DFS:/** * Definition for binary
2017-03-07 21:37:39 262
原创 unicode编码转换
#include <iostream>#include <vector>#include <numeric>#include<limits>#include <cctype>#include <sstream>using namespace std;char trans(char c){ if (isdigit(c)) return c - '0'; el
2017-03-07 13:09:08 586
原创 evaluate-reverse-polish-notation
题目描述Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or another expression. Some examples: ["2", "1", "+", "3", "
2017-03-01 20:47:51 199
原创 single-number
题目描述Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ex
2017-03-01 20:05:21 184
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人