[Leetcode] Product of Array Except Self, Solution

摘要: 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 except ... 阅读全文
posted @ 2015-10-25 15:42 小刀初试 阅读(474) 评论(0) 推荐(0) 编辑

[Leetcode] Different Ways to Add Parentheses, Solution

摘要: Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th... 阅读全文
posted @ 2015-10-18 11:39 小刀初试 阅读(226) 评论(0) 推荐(0) 编辑

[Leetcode] Valid Anagram, Solution

摘要: Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = ... 阅读全文
posted @ 2015-10-18 09:42 小刀初试 阅读(205) 评论(0) 推荐(0) 编辑

[Leetcode] Binary Tree Paths, Solution

摘要: Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->... 阅读全文
posted @ 2015-10-17 14:06 小刀初试 阅读(161) 评论(0) 推荐(0) 编辑

[Leetcode] Single Number III, Solution

摘要: 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 elements ... 阅读全文
posted @ 2015-10-17 13:59 小刀初试 阅读(256) 评论(0) 推荐(0) 编辑

[Leetcode] Ugly Number II, Solution

摘要: 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... 阅读全文
posted @ 2015-10-06 13:21 小刀初试 阅读(189) 评论(0) 推荐(0) 编辑

[Leetcode] Ugly Number, Solution

摘要: Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exam... 阅读全文
posted @ 2015-10-06 12:47 小刀初试 阅读(175) 评论(0) 推荐(0) 编辑

[Leetcode] Move Zeroes, Solution

摘要: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, give... 阅读全文
posted @ 2015-10-03 14:06 小刀初试 阅读(244) 评论(0) 推荐(0) 编辑

[Leetcode] Peeking Iterator, Solution

摘要: Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it e... 阅读全文
posted @ 2015-10-03 12:43 小刀初试 阅读(193) 评论(0) 推荐(0) 编辑

[Leetcode] Find the Duplicate Number, Solution

摘要: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. ... 阅读全文
posted @ 2015-10-03 12:00 小刀初试 阅读(231) 评论(0) 推荐(0) 编辑