
LeetCode平台算法实现
LZTree
对于编程开发兴趣浓烈
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode算法题——ZigZag Conversion
Description: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原创 2017-03-09 21:46:30 · 411 阅读 · 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原创 2017-04-11 21:47:39 · 358 阅读 · 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原创 2017-03-26 21:28:16 · 482 阅读 · 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.算法思想:比较两个已排序的链表的第一个元素,哪一个链表第一个元素小则添加到新的链表中去,并原创 2017-04-12 17:01:42 · 428 阅读 · 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原创 2017-03-17 12:11:30 · 333 阅读 · 0 评论 -
LeetCode算法题——23. Merge k Sorted Lists
题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Subscribe to see which companies asked this question.算法思想: 针对K个排序的链表进行两原创 2017-05-04 20:24:22 · 383 阅读 · 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-04-22 21:11:26 · 356 阅读 · 0 评论 -
LeetCode算法题——24. 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原创 2017-05-05 17:08:00 · 434 阅读 · 0 评论 -
LeetCode算法题——25. 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.k is a positive integer and is less than or equal to the length of the linked list. If the原创 2017-05-05 21:43:34 · 350 阅读 · 0 评论 -
LeetCode算法题——26. 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 p原创 2017-05-05 22:20:49 · 411 阅读 · 0 评论 -
LeetCode算法题——18. 4Sum
题目: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 which gives the sum of target.Note: The s原创 2017-03-26 14:45:27 · 401 阅读 · 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:原创 2017-04-11 20:53:37 · 358 阅读 · 0 评论 -
LeetCode算法题——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. You may assume that each input would have原创 2017-03-24 16:21:03 · 341 阅读 · 0 评论 -
LeetCode算法题——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 th原创 2017-03-03 20:19:11 · 481 阅读 · 0 评论 -
LeetCode算法题——Add Two Numbers
Description: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 number原创 2017-03-09 21:49:24 · 295 阅读 · 0 评论 -
LeetCode算法题——Reverse Integer
Description:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions原创 2017-03-10 11:18:00 · 259 阅读 · 0 评论 -
LeetCode算法题——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 ca原创 2017-03-10 15:38:07 · 328 阅读 · 0 评论 -
LeetCode算法题——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.求出所给数字的个、十、百、千位上的数字,然后对应到相应罗马数字字符class Solution {public: string intToRoman(原创 2017-03-21 17:10:34 · 370 阅读 · 0 评论 -
LeetCode算法题——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.针对罗马字符出现的每个位上所有情况考虑进去,得到相应整形数字class Solution {public: int romanToInt(string原创 2017-03-21 17:11:27 · 328 阅读 · 0 评论 -
LeetCode算法题——14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.算法思想:逐个比对每个字符串的前缀字符,若出现不相等或者其中某个字符已经是最末尾的字符时,跳出循环。C++实现如下:#include #include using namespace std;class原创 2017-03-21 17:12:46 · 286 阅读 · 0 评论 -
LeetCode算法题——Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting th原创 2017-03-12 15:25:23 · 334 阅读 · 0 评论 -
LeetCode算法题——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 zero.Note: The solution set must not原创 2017-03-24 15:11:38 · 402 阅读 · 0 评论 -
LeetCode算法题——27. Remove Element
题目:Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant me原创 2017-05-05 22:33:40 · 402 阅读 · 0 评论