If you work at a place where devs are just code monkeys who implement the orders from on high with no feedback whatsoever or avenue for pushback... get a better job.
How would you swap two integers without using a temporary variable? Seen it before? Pass. Not seen it before? Fail.
Steps, mostly driven by just basically knowing the goal and that there's not many operations that could possibly help:
"a" "b"
"a+b" "b"
"a+b" "-a"
"b" "-a"
"b" "a"
Then once you have that, you can enumerate the downsides to that, look for more efficient and less error-prone ways to proceed.
We were looking for the solution based on XOR which works with only two registers.
We wish you luck with your job search elsewhere.
These interview questions are fairly shit, but they're not _that_ shit, and the people giving them are doing their best.
In nearly 30 years of diverse coding experience, I've never once encountered a situation where this solution would be useful.
That said, its probably more used as a filter for people interested enough in working there to study.
To put it another way - they can already automate solving their leetcode problems by looking up the solution in their database, no need for AI. But that's not the point at all.
If they aren't evaluating how the code you write fits into the context of a real world problem, how can they possibly use it to asses your suitability for the job? Using fake code problems to evaluate candidates is the flawed premise here.
Like I said, they were always able to automate solving those problems by doing a database lookup.
You are contradicting your earlier statements. But yes, a tool that can beat leetcode interviews successfully and reliably is a game changer for candidates who want to make it through these pointless LC interviews as a whole.
Because there was a time we did this, and with tools like Google Search it became dumb, but it took some dinosaurs a really long time to let go of their old ways. Hell, some of them are probably still around.