We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Ice Cream Parlor
- Discussions
Ice Cream Parlor
Ice Cream Parlor
Sort by
recency
|
64 Discussions
|
Please Login in order to post a comment
Hi! Solution in Python3 :) :
Output indices are moved one further because of task requirements. Second index is moved twice in case index() method returns position in shorter array.
JAVA
c# code
return arr.SelectMany((num, index) => arr.Skip(index + 1) .Where(nextNum => num + nextNum == m) .Select(nextNum => new List { index+1, arr.LastIndexOf(nextNum)+1 }) ).FirstOrDefault();
Java solution