Trains the technique from
LeetCode 371Sum of Two IntegersThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
You are writing microcode for a teaching processor whose arithmetic unit was left off the die. The only opcodes available to you are bitwise AND, OR, XOR, NOT, left shift and right shift, plus comparisons and loops.
Two signed sensor readings a and b arrive in registers. Report their combined value.
Your routine must not apply the + or - operators anywhere, and it must not reach for a library routine that performs arithmetic on your behalf. Readings may be negative; the machine stores a register as a 32-bit two's complement word, and every legal total fits in such a word.
Example 1
The two readings come to 23 together.
Example 2
Readings may be negative; sitting 4 above -7 lands on -3.
Example 3
Both registers hold negative readings, and together they come to -43.
Example 4
The two readings cancel, so the routine reports 0.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def get_sum(a: int, b: int) -> int:public int getSum(int a, int b)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.