FastPrepFind the Lowest Set Bit Position
Problems/Find the Lowest Set Bit Position

Find the Lowest Set Bit Position

Expedia logoExpedia● EasyINTERNOAONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two Expedia SDE intern entries name this task. One, from a campus process, puts it in the first video-call interview on September 2, 2021. The other puts it in an online coding round on December 16, 2020. The two entries list mostly the same questions.

The 2021 entry adds one line restating the task, and the 2020 entry gives only its title. A separate card for that title gives the rule (bits counted from the right, starting at 1), samples, and N from 1 to 10^9. Here, one number n is given per call, and n = 0 is also allowed. It has no 1 bit, so the answer is 0.

Our version is about 90% the same as the reported questions.

You are given a non-negative integer n. Write n in binary and number its bits from the right: the last bit is at position 1, the bit before it is at position 2, and so on.

Return the position of the rightmost bit that is 1. If n is 0, it has no 1 bit, so return 0.

Function

rightmostSetBit(n: int) → int

Examples

Example 1

n = 44return = 3

44 in binary is 101100. Reading from the right, positions 1 and 2 hold 0, and position 3 holds the first 1, so the answer is 3.

Example 2

n = 97return = 1

97 in binary is 1100001. It is odd, so its last bit, at position 1, is already 1.

Example 3

n = 655360return = 18

655360 is 10 × 2^16, so in binary it is 1010 followed by sixteen 0s. The lowest 1 of 1010 moves up by 16 places, from position 2 to position 18.

Constraints

  • 0 <= n <= 10^9

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
  • Address on Same PageNVIDIA · OANVIDIA interview questions
  • Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
  • Find the Missing Number from 1 to nGEP · OA
  • Invert Ad Visibility BitsJP Morgan Chase · OAJP Morgan Chase interview questions
  • 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
  • Count Times Using at Most Two DigitsLSEG · OALSEG interview questions
  • Check Whether a Byte Is NonzeroZscaler · ONSITE INTERVIEWZscaler interview questions

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
  • Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public int rightmostSetBit(int n) {
        // Write your code here.
    }
}
Checking account…