Binary Palindromic
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You've got a Google OA in your inbox for August 2024, and Binary Palindromic is on the table. This one trips people up because the palindrome check feels straightforward until you realize you're working in binary representation, not decimal. The trick is converting your number to its binary string, then checking if it reads the same forwards and backwards. If you blank on the conversion logic during the live assessment, StealthCoder will read the problem and surface the pattern instantly so you can code with confidence.
Pattern and pitfall
Binary Palindromic asks you to determine if a number is a palindrome when expressed in binary. The approach is simple: convert the integer to binary (most languages have a built-in method), strip any prefix characters, then compare the string to its reverse. The pitfall is off-by-one errors in string indexing or forgetting to handle edge cases like leading zeros in binary representation. Most candidates overthink this by trying bit manipulation when a string comparison is faster and cleaner. During the OA, if you freeze on the conversion syntax, StealthCoder acts as your hedge, letting you see the exact binary format and confirm your approach before you commit code.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Binary Palindromic cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as palindrome number. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Google's OA.
Google reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Binary Palindromic FAQ
Is this just a string reversal problem disguised?+
Mostly yes. Convert to binary, reverse the string, and compare. The catch is the conversion step. Make sure you understand how your language converts int to binary and whether it includes a prefix like '0b'. Strip it if needed before comparing.
Do I need to handle negative numbers?+
The problem doesn't specify, but Google OAs often test edge cases. Negative numbers in binary can be tricky depending on representation (two's complement, sign-magnitude, etc.). Clarify during the OA or assume positive integers unless told otherwise.
What's the time complexity Google cares about?+
O(log n) because the binary representation of a number has O(log n) digits. Space is also O(log n) for the binary string. This is efficient. Don't overthink optimizing further.
Will they ask me to solve this without string conversion?+
Possibly. You can check palindromes using bit manipulation and math, reversing the binary number manually. It's harder to code cleanly. String approach is safer. If they explicitly ask for bit manipulation, pivot then.
How do I prep for this in 48 hours if I'm rusty?+
Write out the binary for 5-10 test cases by hand (9, 21, 7). Spot the palindromes. Then code the string conversion and reversal once. Run it on your test cases. Done. You don't need more.