Oracle OA, harder than the easy reputation suggests
Oracle OA, harder than the easy reputation suggests
Sharing this since there isn't a lot posted about the Oracle OA specifically, mostly onsite stuff. Passed the OA and just moved on to the phone screen a few days later.
Question was a string manipulation problem on HackerRank. You get a lowercase string and each move lets you swap out a single character for any other letter. The goal is to figure out the minimum number of swaps so no two neighboring characters end up the same. Sounds simple until you actually sit down and try to prove greedy works, since the naive instinct is to just walk left to right and fix runs as you see them, but you have to be careful about how a run of the same letter three or four long gets handled without accidentally creating a new collision with whatever comes after it.
Follow up was basically the same question but they asked what changes if you're restricted to only two letters in the whole alphabet, which forces you to think about parity instead of just greedy scanning.
All test cases had to pass on HackerRank, no partial credit really counted for much. Be familiar with these concepts, greedy proofs come up more than people expect for something billed as an easy round.
Replies (4)
the two letter follow up is a nice touch, most companies just stop at the base problem
did they let you pick language freely or was it fixed to something specific?
picked python, seemed fine on their end
thanks for sharing, oracle OA writeups are rare
test cases on hackerrank for oracle screens are brutal, definitely stricter than I expected too
yeah I got timed out on an edge case even though my logic was right