随笔分类 -  Leetcode (C)

1 2 下一页

22. Generate Parentheses (backTracking)
摘要: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: " 阅读全文

posted @ 2016-04-24 06:51 joannae 阅读(266) 评论(0) 推荐(0)

21. 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. 阅读全文

posted @ 2016-04-18 07:36 joannae 阅读(147) 评论(0) 推荐(0)

20. Valid Parentheses (Stack)
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文

posted @ 2016-04-17 18:05 joannae 阅读(221) 评论(0) 推荐(0)

19. 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 rem 阅读全文

posted @ 2016-04-17 12:10 joannae 阅读(154) 评论(0) 推荐(0)

18. 4Sum (通用算法 nSum)
摘要: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 whic 阅读全文

posted @ 2016-04-17 11:56 joannae 阅读(409) 评论(0) 推荐(0)

17. Letter Combinations of a Phone Number (backtracking)
摘要:Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telepho 阅读全文

posted @ 2016-04-16 15:32 joannae 阅读(246) 评论(0) 推荐(0)

16. 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. 阅读全文

posted @ 2016-04-14 22:32 joannae 阅读(189) 评论(0) 推荐(0)

15. 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 阅读全文

posted @ 2016-04-14 22:02 joannae 阅读(258) 评论(0) 推荐(0)

14. Longest Common Prefix (截取字符串)
摘要:Write a function to find the longest common prefix string amongst an array of strings. 阅读全文

posted @ 2016-04-13 19:22 joannae 阅读(207) 评论(0) 推荐(0)

13. Roman to Integer
摘要:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 阅读全文

posted @ 2016-04-13 18:54 joannae 阅读(162) 评论(0) 推荐(0)

12. Integer to Roman
摘要:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 阅读全文

posted @ 2016-04-08 22:55 joannae 阅读(168) 评论(0) 推荐(0)

11. 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 endpo 阅读全文

posted @ 2016-04-08 15:29 joannae 阅读(217) 评论(0) 推荐(0)

10. Regular Expression Matching
摘要:Implement regular expression matching with support for '.' and '*'. 思路:在出现*的时候,因为可能出现0,1,2,...次,所以要使用到带回溯的递归 阅读全文

posted @ 2016-04-08 06:34 joannae 阅读(123) 评论(0) 推荐(0)

9. Palindrome Number (考虑负数的情况)
摘要:Determine whether an integer is a palindrome. Do this without extra space. 阅读全文

posted @ 2016-04-07 18:22 joannae 阅读(124) 评论(0) 推荐(0)

8. String to Integer (整数的溢出)
摘要:Implement atoi to convert a string to an integer. If no valid conversion could be performed, a zero value is returned. If the correct value is out of 阅读全文

posted @ 2016-04-07 18:15 joannae 阅读(210) 评论(0) 推荐(0)

7. Reverse Integer (整数的溢出)
摘要:Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 For the purpose of this problem, assume that your function 阅读全文

posted @ 2016-04-07 09:12 joannae 阅读(181) 评论(0) 推荐(0)

6. ZigZag Conversion (字符串的连接)
摘要:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 阅读全文

posted @ 2016-04-07 07:14 joannae 阅读(167) 评论(0) 推荐(0)

5. Longest Palindromic Substring (DP)
摘要:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes 阅读全文

posted @ 2016-04-06 15:43 joannae 阅读(167) 评论(0) 推荐(0)

4. Median of Two Sorted Arrays (二分法;递归的结束条件)
摘要:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh 阅读全文

posted @ 2016-04-06 06:32 joannae 阅读(302) 评论(0) 推荐(0)

3. Longest Substring Without Repeating Characters (ASCII码128个,建立哈西表)
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo 阅读全文

posted @ 2016-03-13 11:00 joannae 阅读(247) 评论(0) 推荐(0)

1 2 下一页

导航