Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Is that a combinatorial problem? Lets solve this here! Also, when is such a problem a real thing you would solve? A real world example that falls into this class of problem solving would be interesting.
Step 1: Get yourself a dictionary and make a hash set with all 3 letter words
Step 2: Make a lazy graph where a nodes neighbor has one letter difference.
Step 3: Use a search algorithm of your own choice to find a path to DOG
If you do enough of them youll realize that a lot of problems have simular solutions. And a lot of problems dont even appear in a common job. I have never had to solve traveling merchant or stuff like that in an actual project. So just do them on the side and eventually youll get the hang of them.
Also while i was looking for a job i didn tget questions like that. I mostly had web, sql, backend and frontend framework specific ones. Depends on where and what you apply for.
Usually simpler than that. You're supposed to ask what the criteria for a valid word is, and implement a function to check according to what they state.
It'll be something like "three letter word has to have a vowel in the middle," so the comp set of chars for pos 1 is 6/5 chars wide, positions 0 and 2 are 20/21 chars wide. The bonus pivot there is "is y a vowel?"
It's also generally faster if you convert everything to numbers (char code or discrete enum) which would get you more points.