Advertisement
lazar955

Untitled

Oct 22nd, 2023
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. func twoSum(numbers []int, target int) []int {
  2. i,j:=0,len(numbers)-1
  3. sum:=numbers[i] + numbers[j]
  4. for sum != target {
  5. if sum < target {
  6. i++
  7. }else{
  8. j--
  9. }
  10. sum = numbers[i] + numbers[j]
  11. }
  12. return []int{i+1,j+1}
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement