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

Revision en1, by sahnigwl, 2024-11-07 16:15:16

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 Python mid = l + (r - l)//2

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

Tags binary search

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English sahnigwl 2024-11-07 16:16:40 20 Tiny change: 'ieve both are same' -> 'ieve both should function the same'
en2 English sahnigwl 2024-11-07 16:16:01 29
en1 English sahnigwl 2024-11-07 16:15:16 602 Initial revision (published)