- 博客(54)
- 资源 (1)
- 收藏
- 关注
原创 CODE 116: 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:Elements in a triplet (a,b,c)
2013-11-08 21:23:19 447
原创 CODE 113: 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 string
2013-11-06 21:49:32 537
原创 CODE 112: 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
2013-11-06 20:23:28 519
原创 CODE 111: 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 va
2013-11-06 19:51:53 601
原创 CODE 110: 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:"((()))", "(()())", "(())()", "()(())", "()()
2013-11-05 21:26:28 573
原创 CODE 109: Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. public ListNode mergeKLists(ArrayList lists) { // IMPORTANT: Please reset any member data you
2013-11-05 19:48:01 450
原创 CODE 108: 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
2013-11-04 20:32:03 559
原创 CODE 107: Reverse Nodes in k-Group
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
2013-11-04 20:19:47 638
原创 CODE 106: 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
2013-11-04 19:43:49 578
原创 CODE 105: Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length. pu
2013-11-03 18:59:17 501
原创 CODE 104: Divide Two Integers
Divide two integers without using multiplication, division and mod operator. public int divide(int dividend, int divisor) { // IMPORTANT: Please reset any member data you declared, as // the s
2013-11-03 16:35:51 544
原创 CODE 103: Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an
2013-11-03 14:28:21 544
原创 CODE 102: Next Permutation
public void nextPermutation(int[] num) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. List rest = new ArrayList();
2013-11-01 23:10:05 497
原创 CODE 101: 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 "()", wh
2013-11-01 22:28:45 403
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人