Skip to content

Instantly share code, notes, and snippets.

@vinnymac
Last active September 16, 2019 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinnymac/15df344d7cf53105247be1004324b396 to your computer and use it in GitHub Desktop.
Save vinnymac/15df344d7cf53105247be1004324b396 to your computer and use it in GitHub Desktop.
Daily Coding Problem: Problem #85 [Medium]

Good morning! Here's your coding interview problem for today.

This problem was asked by Facebook.

Given three 32-bit integers x, y, and b, return x if b is 1 and y if b is 0, using only mathematical or bit operations. You can assume b can only be 1 or 0.

function getValue(x, y, b) {
return x * b + y * (1 - b);
}
// getValue(3, 8, 1) -> 3
// getValue(3, 8, 0) -> 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment