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.
- Prepare
- Algorithms
- Search
- Ice Cream Parlor
- Discussions
Ice Cream Parlor
Ice Cream Parlor
+ 0 comments Basically Two Sum
def icecreamParlor(m, arr): d = dict() for idx, price in enumerate(arr): if m - price in d: return [d[m - price], idx + 1] d[price] = idx + 1 return [0,0]
+ 0 comments Python
def icecreamParlor(m, arr): for i in range(len(arr)-1): j = i + 1 while j < len(arr): if arr[i] + arr[j] == m: return i+1, j+1 j += 1
+ 0 comments public static List<Integer> icecreamParlor(int m, List<Integer> arr) { List<Integer> result = new ArrayList<>(); for(int i = 0; i < arr.size() - 1; i++) { int c1 = arr.get(i); for(int j = i + 1; j < arr.size(); j++) { int c2 = arr.get(j); if(c1 + c2 == m) { result.add(i + 1); result.add(j + 1); return result; } } } return result; }
+ 0 comments Python 3
def icecreamParlor(m, arr): for idx, i in enumerate(arr): if arr[idx+1:].count(m-i) > 0: return idx+1, arr[idx+1:].index(m-i)+idx+2
+ 0 comments def icecreamParlor(m, arr): # Write your code here for i,it1 in enumerate(arr): for j,it2 in enumerate(arr[i+1:]): if it1+it2==m: return([i+1,i+1+j+1])
Load more conversations
Sort 848 Discussions, By:
Please Login in order to post a comment