【LeetCode】
Sly_461
这个作者很懒,什么都没留下…
展开
-
LeetCode#2 Add Two Numbers
题目:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return原创 2017-07-05 11:45:40 · 386 阅读 · 0 评论 -
LeetCode#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.题意:就是给你两个已经排好序的链表,然后叫你合并成一个链表。 思路:就是考链表的操作。代码:/** * Defin原创 2017-07-17 20:52:02 · 476 阅读 · 0 评论 -
LeetCode#20 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 valid but “原创 2017-07-17 20:47:54 · 472 阅读 · 0 评论 -
LeetCode#12 Integer to Roman && #13* Roman to Integer(罗马数字转换)
12题: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.13题: Given a roman numeral, convert it to an integer. Input is guaranteed to b原创 2017-07-17 10:34:18 · 456 阅读 · 0 评论 -
LeetCode#15* 3Sum && LeetCode#16 3Sum Closest && LeetCode#18 4Sum
【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 contai原创 2017-07-17 20:37:18 · 927 阅读 · 0 评论 -
LeetCode#17 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 “23原创 2017-07-17 20:36:53 · 584 阅读 · 0 评论 -
LeetCode#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 removing the second node from the end, the link原创 2017-07-17 20:36:22 · 412 阅读 · 0 评论 -
LeetCode#14 Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.题意:写一个函数(或方法)来寻找一个字符串数组中的最长公共前缀。 例如:”abcdefg” ”abcdefghijk” ”abcdfghijk” ”abcef原创 2017-07-17 10:48:01 · 397 阅读 · 0 评论 -
LeetCode#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 endpoints of line i is at (i, ai) and (i, 0). Find two lin原创 2017-07-17 09:59:33 · 534 阅读 · 0 评论 -
LeetCode#9* Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string,原创 2017-07-17 02:43:12 · 420 阅读 · 0 评论 -
LeetCode#8 String to Integer (atoi)
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 below and ask yourself what are the possible input case原创 2017-07-17 02:20:35 · 421 阅读 · 0 评论 -
LeetCode#7 Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers.Note: The input is assumed to be a 32-bit signed integer. Your function shou原创 2017-07-05 19:18:01 · 359 阅读 · 0 评论 -
LeetCode#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 for better legibility) P A H N A P L S I原创 2017-07-05 19:10:19 · 400 阅读 · 0 评论 -
LeetCode#5* Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Input: “babad” Output: “bab” Note: “aba” is also a valid answer.原创 2017-07-05 18:23:00 · 455 阅读 · 0 评论 -
LeetCode#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 should be O(log (m+n)). Example 1: nums1 = [1,原创 2017-07-05 15:36:44 · 404 阅读 · 0 评论 -
LeetCode#3* Longest Substring Without Repeating Characters
题目:Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”, which the length is 3. Given “bbbbb”, the answer is “b原创 2017-07-05 12:52:21 · 304 阅读 · 0 评论 -
LeetCode#1 Two Sum
题意:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same原创 2017-07-05 10:43:04 · 341 阅读 · 0 评论 -
LeetCode#22* 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-07-18 11:45:10 · 505 阅读 · 0 评论