Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.
You may assume that each input would have exactly one solution.
Input: numbers={2, 7, 11, 15}, target=9
Output: index1=1, index2=2
Line 8: cannot find symbol: method size()
Run Status: Compile Error
Line 16: unreported exception java.lang.Exception; must be caught or declared to be thrown
Run Status: Wrong Answer
Showing the first failed test case.| input | output | expected | |
|---|---|---|---|
| [5,75,25], 100 | 1, 2 | 2, 3 |
Run Status: Accepted!
Program Runtime: 488 milli secs
Program Runtime: 488 milli secs
Run Status: Accepted!
Program Runtime: 540 milli secs
Program Runtime: 540 milli secs
796

被折叠的 条评论
为什么被折叠?



