摘要: A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文
posted @ 2016-07-24 14:40 ShawnChang 阅读(342) 评论(0) 推荐(0) 编辑
摘要: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. 给你两个数组nums1和nums2,这两个数组都是递增排列的,还给你一个整数k。 Define a pair (u 阅读全文
posted @ 2016-07-24 08:37 ShawnChang 阅读(269) 评论(0) 推荐(0) 编辑
摘要: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? 给出整数n,有多少中不同的存储着1到n的二叉搜索树。 For example, Given n = 3, there 阅读全文
posted @ 2016-07-18 17:42 ShawnChang 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. 给出一个数组包含n个不同的从0到n取出的数,从中找出一个丢失的的 阅读全文
posted @ 2016-07-17 16:04 ShawnChang 阅读(92) 评论(0) 推荐(0) 编辑
摘要: We are playing the Guess Game. The game is as follows: 我们来玩一个游戏,规则如下: I pick a number from 1 to n. You have to guess which number I picked. 我从1到n之间选择一 阅读全文
posted @ 2016-07-17 15:40 ShawnChang 阅读(558) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array of integers, return the k most frequent elements. 给出一个不为空的整数数组,返回出现频率前k位的数字。 For example, Given [1,1,1,2,2,3] and k = 2, retur 阅读全文
posted @ 2016-07-09 11:08 ShawnChang 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. 给出一个非负整数n,计算出所有没有重复数字的x,其中0≤x<10n。 Example: Given n = 2, r 阅读全文
posted @ 2016-07-08 12:01 ShawnChang 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which the ith element is the price of a given stock on day i. 现在有个数组表示股票每天的价格,其中第i个位置表示的是第i天股票的价格。 Design an algorithm to fi 阅读全文
posted @ 2016-07-07 08:53 ShawnChang 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 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 @ 2016-07-06 18:05 ShawnChang 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. 不使用‘+’和‘-’,计算两个整数的和。 Example: Given a = 1 and b = 2, r 阅读全文
posted @ 2016-07-06 12:51 ShawnChang 阅读(140) 评论(0) 推荐(0) 编辑