自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 unique-binary-search-trees

题目:Given n, how many structurally unique BST’s (binary search trees) that store values 1…n? For example, Given n = 3, there are a total of 5 unique BST’s. 1 3 3 2 1 \

2017-09-25 17:06:37 132

原创 restore-ip-addresses

题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given”25525511135”, return[“255.255.11.135”, “255.255.111.35”]. (Order does

2017-09-25 15:48:41 140

原创 reverse-linked-list-ii

题目:Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given1->2->3->4->5->NULL, m = 2 and n = 4, return1->4->3->2->5->NULL. Note: Given m, n satisfy the foll

2017-09-25 15:12:18 201

原创 subsets-ii

题目: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

2017-09-25 11:45:51 243

原创 decode-ways

题目:A message containing letters fromA-Zis being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determine the total number

2017-09-25 11:26:33 164

原创 gray-code

题目:The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of

2017-09-25 10:19:27 172

原创 merge-sorted-array

题目:Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space to hold additional elements from B. The number of elements initialized in

2017-09-24 19:49:41 221

原创 scramble-string

题目:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 =”great”: great / \ gr

2017-09-24 19:26:40 232

原创 partition-list

题目:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of

2017-09-24 18:53:22 233

原创 maximal-rectangle

题目:Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area.程序:class Solution {public:    int maximalRectangle(vector<vector<char> > &matri

2017-09-24 18:28:47 218

原创 largest-rectangle-in-histogram

题目:Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of ea

2017-09-24 16:04:51 223

原创 remove-duplicates-from-sorted-list-ii

题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given1->2->3->3->4->4->5, return1->2->5. Given1->1->1-

2017-09-22 15:59:07 243

原创 remove-duplicates-from-sorted-list

题目:Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given1->1->2, return1->2. Given1->1->2->3->3, return1->2->3.程序:class Solution { public:

2017-09-22 15:26:53 182

原创 search-in-rotated-sorted-array-ii

题目:Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given target is in the a

2017-09-22 15:13:50 187

原创 remove-duplicates-from-sorted-array-ii

题目:Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice? For example, Given sorted array A =[1,1,1,2,2,3], Your function should return length =5, and A is now[1,1,2,2,3].

2017-09-22 11:44:35 162

原创 word-search

题目:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically

2017-09-22 11:36:12 268

原创 combinations

题目: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

2017-09-21 21:16:25 231

原创 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”. No

2017-09-21 20:56:21 214

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

2017-09-21 20:00:47 174

原创 search-a-2d-matrix

题目:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of each row

2017-09-20 21:40:33 368

原创 set-matrix-zeroes

题目:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution using O(m n

2017-09-20 20:18:55 227

原创 edit-distance

题目:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word:

2017-09-20 20:11:35 204

原创 2018网易--最长公共子括号序列

题目:一个合法的括号匹配序列被定义为: 1. 空串”“是合法的括号序列 2. 如果”X”和”Y”是合法的序列,那么”XY”也是一个合法的括号序列 3. 如果”X”是一个合法的序列,那么”(X)”也是一个合法的括号序列 4. 每个合法的括号序列都可以由上面的规则生成 例如”“, “()”, “()()()”, “(()())”, “(((()))”都是合法的。 从一个字符串S中移除零个或者

2017-09-20 19:55:15 689

原创 2018网易--游历魔法王国

题目:魔法王国一共有n个城市,编号为0~n-1号,n个城市之间的道路连接起来恰好构成一棵树。 小易现在在0号城市,每次行动小易会从当前所在的城市走到与其相邻的一个城市,小易最多能行动L次。 如果小易到达过某个城市就视为小易游历过这个城市了,小易现在要制定好的旅游计划使他能游历最多的城市,请你帮他计算一下他最多能游历过多少个城市(注意0号城市已经游历了,游历过的城市不重复计算)。 输入描述:

2017-09-18 21:48:20 1101

原创 2018网易秋招--合唱

题目:小Q和牛博士合唱一首歌曲,这首歌曲由n个音调组成,每个音调由一个正整数表示。 对于每个音调要么由小Q演唱要么由牛博士演唱,对于一系列音调演唱的难度等于所有相邻音调变化幅度之和, 例如一个音调序列是8, 8, 13, 12, 那么它的难度等于|8 - 8| + |13 - 8| + |12 - 13| = 6(其中||表示绝对值)。 现在要对把这n个音调分配给小Q或牛博士,让他们演唱的难度之

2017-09-18 20:31:40 775

原创 simplify-path

题目:Given an absolute path for a file (Unix-style), simplify it. For example, path =”/home/”, =>”/home” path =”/a/./b/../../c/”, =>”/c” click to show corner cases. Corner Cases:Did you consider the

2017-09-16 10:10:42 334

原创 climbing-stairs

题目:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?程序:class Solution {public:

2017-09-16 09:29:19 147

原创 sqrtx

题目:Implementint sqrt(int x). Compute and return the square root of x.程序:class Solution {public: int sqrt(int x) {//思路用二分法 if (x < 2) return x; int left = 1, right = x

2017-09-16 09:11:58 279

原创 text-justification

题目:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your words in a greedy approach; that i

2017-09-16 08:42:54 243

原创 valid-number

题目:Validate if a given string is numeric. Some examples: “0”=>true ” 0.1 “=>true “abc”=>false “1 a”=>false “2e10”=>true Note: It is intended for the problem statement to be ambiguous. You should

2017-09-15 16:50:01 220

原创 merge-two-sorted-lists

题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.程序:class Solution {public: ListNode *mergeTwoLists(L

2017-09-15 16:22:02 181

原创 minimum-path-sum

题目:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at

2017-09-15 16:12:51 208

原创 unique-paths-ii

题目:Follow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as1and0respectively in the grid. F

2017-09-15 16:07:09 184

原创 unique-paths

题目: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

2017-09-15 15:47:15 158

原创 rotate-list

题目:Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given1->2->3->4->5->NULLand k =2, return4->5->1->2->3->NULL.程序:class Solution {public: ListNode *

2017-09-15 15:12:18 201

原创 permutation-sequence

题目:The set[1,2,3,…,n]contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): “123” “132” “213” “231”

2017-09-15 15:00:05 192

原创 spiral-matrix-ii

题目:Given an integer n, generate a square matrix filled with elements from 1 to n 2 in spiral order. For example, Given n =3, You should return the following matrix: [ [ 1, 2, 3 ], [ 8, 9, 4 ],

2017-09-15 10:53:28 173

原创 length-of-last-word

题目:Given a string s consists of upper/lower-case alphabets and empty space characters’ ‘, return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defi

2017-09-15 09:55:08 242

原创 insert-interval

题目:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Exa

2017-09-15 09:34:59 198

原创 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].程序:class Solution {public: vector<Interval> merge(v

2017-09-15 09:26:15 279

空空如也

空空如也

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

TA关注的人

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