Check Whether a Byte Is Nonzero
Updated
Problem statement
Given a nonnegative 64-bit integer value and a zero-based byte index byteIndex, return whether the selected byte is nonzero.
Byte index 0 is the least-significant byte. Each byte contains 8 bits.
Function
isByteNonzero(value: long, byteIndex: int) → booleanExamples
Example 1
value = 305419896byteIndex = 0return = trueThe least-significant byte is hexadecimal 78, which is nonzero.
Example 2
value = 16711680byteIndex = 1return = falseThe value is hexadecimal 00FF0000; byte index 1 is 00.
Example 3
value = 0byteIndex = 7return = falseEvery byte of zero is zero.
Constraints
0 <= value <= 2^63 - 10 <= byteIndex <= 7
More Zscaler interview questions
- Asteroid CollisionONSITE INTERVIEW · Seen Sep 2024
- Count Vowel PermutationsONSITE INTERVIEW · Seen Sep 2024
- Longest Common Subsequence LengthONSITE INTERVIEW · Seen Jun 2024
- Run-Length EncodingONSITE INTERVIEW · Seen Jun 2024
- Rate Limiter with Hourly and Daily Effort QuotasPHONE SCREEN · Seen Jul 2026
- Merging PalindromesPHONE SCREEN · Seen Sep 2024
- Find the Element With Odd FrequencyPHONE SCREEN · Seen Jun 2024
- Merge IntervalsPHONE SCREEN · Seen Jun 2024
- Sum of Divisors of the Array GCDPHONE SCREEN · Seen Jun 2024
- How Many Sentences? 🌿OA · Seen Mar 2024
Similar questions at other companies
- Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
- Swap Two Integers Without a Temporary VariableOracle · ONSITE INTERVIEWOracle interview questions
- Add Two Binary StringsPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Add BinaryMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Find the Lowest Set Bit PositionExpedia · OA · ONSITE INTERVIEWExpedia interview questions
- Bayesian Scenario ClassifierAmazon · ONSITE INTERVIEW
- K-th Amount a Payout Machine Can GiveRippling · ONSITE INTERVIEWRippling interview questions
- First Register Overflow TickNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
- Product of Two Integers Without MultiplyingCapital One · ONSITE INTERVIEWCapital One interview questions
- Minimum Testers to Find the Poisoned BottleWalleye Capital · OA