随笔分类 -  LeetCode

摘要:题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set i... 阅读全文
posted @ 2015-03-20 21:56 Sawyer Ford 阅读(181) 评论(0) 推荐(0)
摘要:题目描述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in ... 阅读全文
posted @ 2015-03-11 15:18 Sawyer Ford 阅读(206) 评论(0) 推荐(0)
摘要:题目描述: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. A... 阅读全文
posted @ 2015-03-11 08:25 Sawyer Ford 阅读(181) 评论(0) 推荐(0)
摘要:题目描述:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the tel... 阅读全文
posted @ 2015-03-05 15:09 Sawyer Ford 阅读(152) 评论(0) 推荐(0)
摘要:题目描述:Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the su... 阅读全文
posted @ 2015-02-11 10:15 Sawyer Ford 阅读(129) 评论(0) 推荐(0)
摘要:题目描述:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target.Return the sum of the three integers.Yo... 阅读全文
posted @ 2015-02-10 18:46 Sawyer Ford 阅读(145) 评论(0) 推荐(0)
摘要:题目描述:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:E... 阅读全文
posted @ 2015-02-09 14:53 Sawyer Ford 阅读(193) 评论(0) 推荐(0)
摘要:题目描述:Write a function to find the longest common prefix string amongst an array of strings. 题目很唬人,搞清楚前缀的意思就简单了。解题思路就四个字:垂直匹配。solution:string longestC... 阅读全文
posted @ 2015-02-08 11:23 Sawyer Ford 阅读(145) 评论(0) 推荐(0)
摘要:题目描述:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999. 这道题很简单,我就直接贴答案了。solution1:int romanTo... 阅读全文
posted @ 2015-02-06 21:37 Sawyer Ford 阅读(173) 评论(0) 推荐(0)
摘要:题目描述:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999. 这道题我必须炫一下,因为提交一次就成功了,而且代码很赞。solution:... 阅读全文
posted @ 2015-02-06 08:50 Sawyer Ford 阅读(156) 评论(0) 推荐(0)
摘要:题目描述: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 ... 阅读全文
posted @ 2015-02-05 10:37 Sawyer Ford 阅读(146) 评论(0) 推荐(0)
摘要:题目描述:Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding elemen... 阅读全文
posted @ 2015-02-02 10:36 Sawyer Ford 阅读(148) 评论(0) 推荐(0)
摘要:题目描述: Determine whether an integer is a palindrome. Do this without extra space.solution1: //依次比较高位和低位数字是否相同bool isPalindrome(int x) { if(x... 阅读全文
posted @ 2015-01-16 10:05 Sawyer Ford 阅读(194) 评论(0) 推荐(0)
摘要:题目描述:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see be... 阅读全文
posted @ 2014-12-28 16:49 Sawyer Ford 阅读(158) 评论(0) 推荐(0)
摘要:题目摘要:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321 这道题不算难,主要是要考虑"反转后的值可能越界"这一种情况。(此题起初设计时,未考虑这种情况,因此网上很多旧... 阅读全文
posted @ 2014-12-22 11:28 Sawyer Ford 阅读(145) 评论(0) 推荐(0)
摘要:题目描述: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 ... 阅读全文
posted @ 2014-12-19 19:54 Sawyer Ford 阅读(195) 评论(0) 推荐(0)
摘要:题目描述: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 l... 阅读全文
posted @ 2014-12-17 15:26 Sawyer Ford 阅读(202) 评论(0) 推荐(0)
摘要:题目描述:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a si... 阅读全文
posted @ 2014-12-11 14:37 Sawyer Ford 阅读(181) 评论(0) 推荐(0)
摘要:题目描述:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating lette... 阅读全文
posted @ 2014-12-05 19:13 Sawyer Ford 阅读(169) 评论(0) 推荐(0)
摘要:题目描述: There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sho... 阅读全文
posted @ 2014-12-02 17:28 Sawyer Ford 阅读(166) 评论(0) 推荐(0)