Intersection of Two Linked Lists

2018-09-05
阅读 2 分钟
1.2k
Write a program to find the node at which the intersection of twosingly linked lists begins. For example, the following two linked lists: A: a1 → a2 {代码...} Notes: If the two linked lists have no intersection at all, return null. Thelinked lists must retain their original structure after the fu...

209. Minimum Size Subarray Sum

2018-08-29
阅读 2 分钟
1.7k
Given an array of n positive integers and a positive integer s, findthe minimal length of a contiguous subarray of which the sum ≥ s. Ifthere isn't one, return 0 instead.Example: Input: s = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: the subarray[4,3] has the minimal length under the problem c...

27 Remove Element

2018-08-29
阅读 2 分钟
1.3k
Given an array nums and a value val, remove all instances of thatvalue in-place and return the new length.Do not allocate extra space for another array, you must do this bymodifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn't matter what you l...

344 Reverse String

2018-08-28
阅读 2 分钟
1.4k
Write a function that takes a string as input and returns the stringreversed.Example 1: Input: "hello" Output: "olleh" Example 2: Input: "A man, a plan, a canal: Panama" Output: "amanaP :lanac a ,nalpa ,nam A"