自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Merge K Sorted List

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.11/3 这道题也跟狗家的onsite有点像, 虾米

2014-11-04 04:02:06 307

原创 Permutation II

Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].

2014-11-04 02:18:10 337

原创 Container with Most Water

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin

2014-11-04 00:55:28 272

原创 LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if

2014-11-04 00:39:38 351

原创 Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total

2014-11-03 04:17:51 329

原创 Sort Color

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 integers 0,

2014-11-03 03:46:03 254

原创 Wildcard Matching

11/1这个难题一遍组public class Solution { public boolean isMatch(String s, String p) { int slen = s.length(), plen = p.length(); int ss = 0, pp = 0; int sc = -1, pc

2014-11-02 10:19:16 238

原创 Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st

2014-11-02 07:56:14 264

原创 Longest Substring without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For

2014-11-02 06:58:56 186

原创 Max-Sum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] has

2014-11-02 06:42:31 301

原创 Binary Tree: Inorder Traversal

11/1the classic inorder traversal, takes O(n) time and O(1) space

2014-11-02 06:19:12 273

原创 First Missing Integer

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 constant spa

2014-11-02 05:23:07 204

原创 Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,

2014-11-02 04:44:27 247

原创 Unique Path

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo

2014-11-02 04:28:09 295

原创 Palindromic Number

in O(1) spacecompare the most significant an

2014-11-02 01:33:30 276

原创 Longest Valid Parenthesis

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", wh

2014-11-02 00:59:30 224

原创 Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total

2014-11-02 00:34:53 244

原创 Divide Two Integers

return x/y11/1在cpublic class Solution { public int divide(int x, int y) { // return x/y /* * edge cases: * 1. x and y could be negative * 2. if

2014-11-01 23:50:02 301

原创 Sort LinkedList

In O(nlgn) time.使用merge sort, 由于使用了递归, 复杂度 T(n) 巍峨

2014-11-01 23:07:58 365

原创 Combination Sum

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]

2014-11-01 22:48:54 251

原创 Anagrams

Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.10/31Solutions:The key is to

2014-11-01 10:22:04 236

原创 Subsets

Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplica

2014-11-01 09:51:02 222

原创 reverse K listnodes

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

2014-11-01 09:03:24 364

原创 Max Path Sum

public class Solution { public int maxPathSum(TreeNode root) { if(root == null) return 0; return maxPathSum(root, new int[1]); } private int maxPathSum(TreeNode roo

2014-11-01 08:36:28 364

原创 Roate image by 90 degree in place

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?

2014-11-01 05:43:27 459

原创 valid BST

Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.The

2014-11-01 05:09:04 365

原创 remove duplicate from sorted list(keep only 1 per element)

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with c

2014-11-01 05:03:19 399

原创 Merge Intervals

Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].这道题是我在面某

2014-11-01 04:49:00 236

原创 3 Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c)

2014-11-01 03:44:48 236

原创 Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Solution 1(

2014-11-01 03:08:09 217

原创 Next Permutation

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o

2014-11-01 02:33:25 198

原创 Simplify path

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"

2014-11-01 02:01:04 262

原创 Pascal Triangle

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?

2014-10-31 23:46:15 473

原创 jump game II

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to

2014-10-31 23:27:44 247

原创 经典题find median of two sorted array

10/30大概写了15分钟, 3个错, 两个typo, 一个

2014-10-31 05:08:50 523

原创 Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".

2014-10-25 02:58:13 218

原创 If a string is Palindromic

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a pa

2014-10-25 02:20:35 349

原创 Clone Graph

Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each

2014-10-24 05:18:41 256

原创 Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to {1,4

2014-10-24 04:55:45 237

原创 Maximum Product Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the largest pr

2014-10-24 03:43:24 245

空空如也

空空如也

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

TA关注的人

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