
leetcode
文章平均质量分 57
steph_curry
这个作者很懒,什么都没留下…
展开
-
leetcode求和问题
一、Two SumGiven 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原创 2018-01-14 20:43:59 · 374 阅读 · 0 评论 -
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原创 2018-01-14 22:31:44 · 100 阅读 · 0 评论 -
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:[ "((()))", "(()())", "(())()", "()(())",原创 2018-01-15 15:21:55 · 116 阅读 · 0 评论 -
21 Merge Two Sorted Lists &&23. Merge k 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.Example:Input: 1->2->4, 1->3->4Output: 1->1->2->3->4->原创 2018-01-15 17:39:51 · 118 阅读 · 0 评论 -
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.思路:很简单,交换相邻两个节点的值就可以了。总个数是奇数的话最后一个结点保持不变。struc原创 2018-01-15 18:41:16 · 128 阅读 · 0 评论 -
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 number o原创 2018-01-15 18:54:57 · 129 阅读 · 0 评论 -
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 by modifying原创 2018-01-15 19:14:45 · 101 阅读 · 0 评论 -
28. Implement strStr()
Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Exampl原创 2018-01-15 20:26:28 · 149 阅读 · 0 评论