自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(24)
  • 收藏
  • 关注

原创 Find Minimum in Rotated Sorted Array II

题目:Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at som

2015-08-30 21:41:21 193

原创 字符串split

# The built-in .split() procedure works# okay, but fails to find all the words on a page# because it only uses whitespace to split the# string. To do better, we should also use punctuation# ma

2015-08-30 09:35:55 228

原创 网易笔试题

题目:给予36个车,6个车道,如和在最短的时间内确定前三名?解题思路:首先比较6次,确定前六名。然后,前三名必然在第一组的前三个,第二组的前二个,第三组的前一个中。(去掉不可能位于前三的)需要两次。总共,需要8次。

2015-08-29 20:33:33 309

原创 Find Minimum in Rotated Sorted Array

题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate e

2015-08-27 10:16:05 196

原创 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 ofnums except nums[i].Solve it without division 

2015-08-26 19:24:16 231

原创 First Missing Positive

题目:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses

2015-08-26 16:15:11 209

原创 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 algori

2015-08-26 15:44:08 221

原创 Basic Calculator II

题目:Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer divisi

2015-08-23 20:44:06 191

原创 Basic Calculator

题目:Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers

2015-08-22 21:00:35 200

原创 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: ["

2015-08-21 19:20:38 195

原创 Implement Stack using Queues

题目:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Re

2015-08-21 18:52:13 206

原创 Valid Parentheses

题目:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are

2015-08-21 18:18:25 190

原创 日期问题

问题:给定两个日期,求他们之间的days解题思路:用最朴素的思路:一天天的数。伪码如下所示:days = 0while date1 is before date2date1 = date1's nextdaydays++return days整体思路就是如上所示,解决该题便基于此一步步下去。由此题,要体会将现实问题用程序解决的一般步骤。代码:def

2015-08-21 10:57:36 230

原创 Pascal's Triangle II

题目:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?解题思路:

2015-08-20 23:18:47 208

原创 Pascal's Triangle

题目:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]解题思路:就是简单的找规律,不解释

2015-08-20 23:04:23 176

原创 Add Binary

题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".解题思路:class Solution:    # @param {string} a    # @param {string} b

2015-08-20 20:41:59 227

原创 Add Digits

题目:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2

2015-08-19 22:00:49 182

原创 Happy Number

题目:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of th

2015-08-19 19:38:51 198

原创 Maximum Gap

题目:Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2

2015-08-19 19:14:15 239

原创 Sort Colors

题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the

2015-08-19 15:47:18 202

原创 Largest Number

题目:Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result

2015-08-19 12:31:39 260

原创 Isomorphic Strings

题目:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced

2015-08-18 09:42:58 186

原创 Group Anagrams

题目:Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]

2015-08-17 11:07:48 1383

原创 Valid Anagram

题目: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 = "car", return false.Note:Yo

2015-08-16 10:27:49 201

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

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