swapPairs

题目

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.

阅读全文

mergeKLists

题目

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

阅读全文

generateParenthesis

题目

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

阅读全文

mergeTwoLists

题目

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.

阅读全文

isValid

题目

Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid.

阅读全文

letterCombinations

题目

Given a digit string, return all possible letter combinations that the number could represent.

阅读全文

removeNthFromEnd

题目

Given a linked list, remove the nth node from the end of list and return its head.
For example,

阅读全文

threeSumClosest

题目

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 exactly one solution.

阅读全文

threeSum

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.

阅读全文

longestCommonPrefix

题目

Write a function to find the longest common prefix string amongst an array of strings.

阅读全文