What do Java coding rounds in interviews actually test, beyond whether you can write the algorithm?
They give you a hard problem on purpose, because the algorithm is not what they are testing. A problem that is hard enough to make you think is a problem where they can watch how you think.
Here is what they are actually looking at.
The first thing is how you break the problem down. Whether you ask about the input, the output, and the size of the data before you write anything. The candidates who do well are the ones who spend two minutes thinking before typing.
The second thing is how you handle the edge cases. The empty list, the list with one item, the duplicate values, the null. A solution that handles the ordinary case and then breaks on the empty case is much worse than one that handles both.
The third thing is whether you talk while you work. They cannot hear you thinking, so a silent twenty minutes tells them nothing.
The fourth thing is whether you test your own work. Running a small case by hand and saying the answer out loud is the single clearest signal that you are careful.
The fifth thing is whether you notice the complexity. Saying "this is O of n squared" after writing a loop shows that you understand what you wrote.
The next question in this topic looks at what to do when you are stuck.