News for hackers. Stuff that matters.
Re:Ask HN: Joining Big Tech in One’s 40s by matt-attack on Tuesday January 07, 2020 @04:23PM (#21985047)
> You must make sure your result is the smallest in lexicographical order among all possible results.

Can someone explain this? I can't even parse that sentence.

Re:Ask HN: Joining Big Tech in One’s 40s by Blakestr on Tuesday January 07, 2020 @04:48PM (#21985306)
Basically alphabetical order, but if you don't say lexicographical, it doesn't sound as smart. (I am assuming it's a more comprehensive term, having to do with other characters, other than simple letters, so that if integers were used, it would appear as 1234, where saying "in alphabetical order"doesn't make sense. But yeah, I did a double take.
Re:Ask HN: Joining Big Tech in One’s 40s by grahamburger on Tuesday January 07, 2020 @11:42PM (#21988419)
If you remove the duplicates from the string:

CACB

You can get either CAB or ACB. If you were to order all of the possible results of removing duplicates (in this case only two, but obviously many more for more complex strings) and order them alphabetically, then take the lowest one, that would be the right answer.

Re:Ask HN: Joining Big Tech in One’s 40s by kayoone on Tuesday January 07, 2020 @04:45PM (#21985264)
in other words, the shortest string in alphabetical order
Re:Ask HN: Joining Big Tech in One’s 40s by shric on Tuesday January 07, 2020 @04:56PM (#21985406)
Smallest as in order not length.

In the second example with input cbacdcbc a possible solution would be cbad but acdb is "smaller" (ordered before).

Re:Ask HN: Joining Big Tech in One’s 40s by logfromblammo on Tuesday January 07, 2020 @06:39PM (#21986515)
It seems odd to want to preserve the ordering among the surviving letters while still involving alphabetical order somehow. Those motives are usually mutually exclusive in the real world.

As an engineer, before starting to code, I'd first ask if the customer would prefer "abcd" or "cbad" for the second example, as either would be far cheaper in terms of development and maintenance costs to do. It's somewhat common to discover that they're just taking the "acdb" you're giving them because that's exactly what they asked for, and then they're alphabetizing it to "abcd" afterward on their end, anyway. But sometimes, there is a legit reason for the weirdness, and the customer is willing to pay for the extra effort.

Whenever someone seems intent on aiming at foot and pulling trigger, always ask "Are you sure?" and "Why do you want that?" at least once before helping them do what they want.

The "read hypothetical; code answer" type of test doesn't quite capture that like the interactive interview discussion does.