- 博客(12)
- 资源 (16)
- 收藏
- 关注
原创 Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm shoul
2016-01-30 22:39:50 309
原创 Single Number III
iven an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Given n
2016-01-30 21:32:20 304
原创 Binary Tree Paths
Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: ["1->2->5", "1->3"] /**
2016-01-30 20:31:01 299
原创 Ugly Number II
Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10
2016-01-28 23:07:10 260
原创 Power of Three
Given an integer, write a function to determine if it is a power of three. class Solution { public: bool isPowerOfThree(int n) { if (n == 0) { return false; }
2016-01-27 20:56:32 325
原创 Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do it in p
2016-01-26 00:44:54 370
原创 Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the
2016-01-23 23:37:05 210
原创 Word Pattern
Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Examp
2016-01-20 22:29:19 347
原创 单词接龙 II
给出两个单词(start和end)和一个字典,找出所有从start到end的最短转换序列 比如: 每次只能改变一个字母。 变换过程中的中间单词必须在字典中出现。 样例 给出数据如下: start = "hit" end = "cog" dict = ["hot","dot","dog","lot","log"] 返回 [ [
2016-01-19 02:27:55 1560
原创 图是否是树
给出 n 个节点,标号分别从 0 到 n - 1 并且给出一个 无向 边的列表 (给出每条边的两个顶点), 写一个函数去判断这张`无向`图是否是一棵树 样例 给出n = 5 并且 edges = [[0, 1], [0, 2], [0, 3], [1, 4]], 返回 true. 给出n = 5 并且 edges = [[0, 1], [1, 2], [2, 3]
2016-01-09 00:53:22 920
原创 二叉树的序列化和反序列化
设计一个算法,并编写代码来序列化和反序列化二叉树。将树写入一个文件被称为“序列化”,读取文件后重建同样的二叉树被称为“反序列化”。 如何反序列化或序列化二叉树是没有限制的,你只需要确保可以将二叉树序列化为一个字符串,并且可以将字符串反序列化为原来的树结构。 样例 给出一个测试数据样例, 二叉树{3,9,20,#,#,15,7},表示如下的树结构:
2016-01-07 01:22:29 3767 2
原创 直方图最大矩形覆盖
给出的n个非负整数表示每个直方图的高度,每个直方图的宽均为1,在直方图中找到最大的矩形面积。 以上直方图宽为1,高度为[2,1,5,6,2,3]。 最大矩形面积如图阴影部分所示,含有10单位 样例 给出 height = [2,1,5,6,2,3],返回 10 struct Value { Value(int a, int b) {
2016-01-05 00:30:55 664
exceptional c++ style中文版 pdf 刘未鹏译
2010-09-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人