Binary search question : 2 ways to write mid, one gets AC but the other does not

Правка en2, от sahnigwl, 2024-11-07 16:16:01

Hi folks,

While solving this question : Packing Rectangles

I submitted two codes which basically did the same thing, the only difference was :

  1. Verdict : Failed on test case 7 : Submission mid = l + (r - l)//2

  2. Verdict : Accepted Submission mid = (l + r) >> 1
    Can someone explain what caused this because, I believe both are same

Теги binary search

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский sahnigwl 2024-11-07 16:16:40 20 Tiny change: 'ieve both are same' -> 'ieve both should function the same'
en2 Английский sahnigwl 2024-11-07 16:16:01 29
en1 Английский sahnigwl 2024-11-07 16:15:16 602 Initial revision (published)