4
drewbie
209d

# I am preparing for interviews and brushing up on my algorithms. I understand what BFS and DFS do, but trying to transform the word CAB to DOG ...and making sure each time you change the word it's a valid word... Like what the fuck? Who thinks of these problems. I am getting very discouraged when it comes to these "Medium" problems (or at least like this). I don't know how to approach them. Reading the solution just feels like cheating and I should be able to get there by myself. Can anyone help me not feel discouraged? I just feel very shitty right now.

• 0
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.
• 3
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
• 2
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.
• 0
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.
• 2
@24th-Dragon I have learned to solve tougher problems during coding challenges. Gained some insights to solving certain class of problems. Have I seen the same problems in my main work? Not very much.
• 1
@24th-Dragon
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.