[Solution]Problem 79: Checking for a value[Facebook/Meta]
Math, Problem Solving, Logic Operators, Boolean
Hey, it’s your favorite cult leader here 🐱👤
On Thursdays, I will send you a problem + its solution. These solutions will help you reinforce your fundamental concepts, improve your problem-solving, and kill those Leetcode-Style Interviews. 🔥🔥💹💹
To get access to all my articles and support my crippling chocolate milk addiction, consider subscribing if you haven’t already!
p.s. you can learn more about the paid plan here.
This solution is going to be a deceptively simple one in terms of code.
But the build-up to the solution really packs a punch. It’s a technique you will see all the time in computational problem-solving. This question will serve as an introduction to it.
Hope you’re excited about it.
Problem
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.
Keep reading with a 7-day free trial
Subscribe to Technology Made Simple to keep reading this post and get 7 days of free access to the full post archives.