144. 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 / ...

2016-03-31 18:53:18

阅读数:227

评论数:0

319. Bulb Switcher

There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every...

2016-03-31 11:51:39

阅读数:110

评论数:0

238. Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums...

2016-03-30 13:30:27

阅读数:162

评论数:0

260. Single Number III

Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elemen...

2016-03-30 12:13:27

阅读数:106

评论数:0

338. Counting Bits

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and ...

2016-03-30 00:23:55

阅读数:198

评论数:0

189. Rotate Array

Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4...

2016-03-29 12:04:52

阅读数:159

评论数:0

8. String to Integer (atoi)

Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see be...

2016-03-28 00:45:46

阅读数:133

评论数:0

155. Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack.pop() -- Re...

2016-03-27 23:26:12

阅读数:115

评论数:0

278. First Bad Version

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality ...

2016-03-26 23:52:30

阅读数:245

评论数:0

1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would hav...

2016-03-25 20:37:24

阅读数:135

评论数:0

6. ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in ...

2016-03-25 20:05:15

阅读数:157

评论数:0

204. Count Primes

Description: Count the number of prime numbers less than a non-negative number, n. 本以为是个求素数的大水题,想都没想直接写了下面代码,结果直接TLE。 class Solution { publi...

2016-03-24 16:15:23

阅读数:123

评论数:0

228. Summary Ranges

iven a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2",&q...

2016-03-23 21:34:40

阅读数:119

评论数:0

303. Range Sum Query - Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -...

2016-03-23 19:38:00

阅读数:136

评论数:0

28. Implement strStr()

Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 题目就是 字符串匹配。 ...

2016-03-23 17:26:11

阅读数:118

评论数:0

67. Add Binary

Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". ...

2016-03-23 16:02:06

阅读数:240

评论数:0

234. Palindrome Linked List(链表模板)

Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 思路1:遍历一边链表,把它放到数组或VECTOR里,转化为字...

2016-03-23 15:33:07

阅读数:173

评论数:0

14. Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings. Subscribe to see which companies asked this question 求...

2016-03-22 23:38:06

阅读数:207

评论数:0

257. 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...

2016-03-21 21:56:12

阅读数:225

评论数:0

203. Remove Linked List Elements

Remove all elements from a linked list of integers that have value val. Example Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, v...

2016-03-21 20:45:44

阅读数:187

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭