- 博客(31)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode 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"]]Note: Al
2017-01-26 16:59:20 185
原创 LeetCode Rotate Image
ou 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?因为顺时针选择90度是图形旋转中的特殊情况,通过找到特殊情况中的元素之间的规律进行求解。思路一:
2017-01-26 16:10:39 424
原创 LeetCode Permutations 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], [2,1
2017-01-26 15:02:30 231
原创 LeetCode Permutations
Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1
2017-01-26 13:58:57 151
原创 LeetCode Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku
2017-01-25 16:55:05 195
原创 LeetCode Multiply Strings
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits
2017-01-25 11:27:16 471
原创 LeetCode 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 constant
2017-01-25 09:10:48 171
原创 Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina
2017-01-24 13:39:49 148
原创 LeetCode Combination Sum
Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen
2017-01-24 11:00:24 143
原创 LeetCode Longest Valid Parentheses
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 "()",
2017-01-20 14:26:09 127
原创 LeetCode Search in Rotated Sorted Array
Suppose an array sorted in ascending order 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).You are given a target value to search. If foun
2017-01-16 13:41:52 172
原创 LeetCode Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.
2017-01-16 08:44:01 242
原创 LeetCode Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially filled
2017-01-14 21:32:11 167
原创 LeetCode Search for a Range
Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the
2017-01-13 16:33:11 282
原创 LeetCode 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".
2017-01-13 15:26:56 171
原创 LeetCode Substring with Concatenation of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and
2017-01-12 16:03:21 161
原创 LeetCode Next Permutation
mplement 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 or
2017-01-12 10:16:26 178
原创 LeetCode Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())
2017-01-11 10:45:30 220
原创 LeetCode Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.
2017-01-10 15:08:32 181
原创 LeetCode Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.这一道题目其实就是k路归并,十分经典的问题。这个可以说是大数据相关或后台面试经常问到的问题。当初面企鹅面到类似的问题没有答上来,技术渣渣啊。。。思路一:分别进行两两归并,直至最
2017-01-10 14:30:31 200
原创 LeetCode Remove Duplicates from Sorted Array
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
2017-01-10 09:31:58 159
原创 LeetCode Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y
2017-01-09 16:52:55 160
原创 LeetCode 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.思路一:单刀直入代码如下:/** * Definition for singly-linked
2017-01-09 14:48:33 133
原创 LeetCode 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 all vali
2017-01-06 17:00:52 153
原创 LeetCode Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the
2017-01-06 09:41:30 155
原创 LeetCode 4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution
2017-01-05 16:26:43 201
原创 LeetCode Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st
2017-01-05 15:30:13 142
原创 LeetCode 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact
2017-01-05 14:22:39 158
原创 LeetCode 3Sum
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: The solution set must not contain
2017-01-05 11:26:46 169
原创 LeetCode Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.关于这个题目的描述有歧义,究竟是求解所有字符串的最长公共前序,还是求解每对字符串中的最长的公共子序列。本题的实际是前一种情况。思路一:思路很直接,就像直男癌一样。。。但需要注意边界输入的处理代码如下:
2017-01-03 14:01:10 192
原创 LeetCode 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
2017-01-03 10:34:11 148
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人