Advertisement
lazar955

Untitled

Oct 24th, 2023
921
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.44 KB | None | 0 0
  1. func findMin(nums []int) int {
  2.     l,r:=0,len(nums) -1
  3.     res:=nums[0]
  4.     for l<=r {
  5.         if nums[l] < nums[r] {
  6.             res = min(res,nums[l])
  7.             break
  8.         }
  9.         m:=(l+r)/2
  10.         res = min(res,nums[m])
  11.         if nums[m] >= nums[l] {
  12.             l = m + 1
  13.         }else {
  14.             r = m - 1
  15.         }
  16.     }
  17.     return res
  18. }
  19.  
  20. func min(l,r int) int {
  21.     if l> r{
  22.         return r
  23.     }
  24.     return l
  25. }
Advertisement
Comments
  • Orcie
    1 year (edited)
    # text 0.24 KB | 0 0
    1. Filter bypass tests if u want them for pastes:
    2. І Love dісk so much і just want to rіde іt all day long~
    3. God does dісk сumming іnsіde of me feel so good darlіng~..
    4. F..fuск dаrlіng-.. You impаle my ѵіrgіnа sо gооd-..!
Add Comment
Please, Sign In to add comment
Advertisement