Grokking Microsoft Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
 sealess
Simple solution with 2 pointers

sealess

Mar 6, 2024

class Solution: def search(self, arr, target_sum): # TODO: Write your code here l, r = 0, len(arr) - 1 while l<r: curr= arr[l] + arr[r] if curr>target_sum: r-=1 elif curr<target_sum: l+=1 else: return [l,r] return [-1, -1]

1

0

Comments
Comments

On this page