Re: [閒聊] 每日LeetCode

作者: SecondRun (雨夜琴聲)   2024-02-21 09:38:38
201. Bitwise AND of Numbers Range
給你left跟right兩個整數
回傳left AND left+1 AND left+2 AND ... AND right
C# code:
public class Solution {
public int RangeBitwiseAnd(int left, int right) {
while(right > left) right &= right-1;
return right;
}
}

Links booklink

Contact Us: admin [ a t ] ucptt.com