3 ms·
Reading the technical questions made me realize how crappy a programmer I am, algorithms-wise.
by Hexstream 18y ago
Reading the technical questions made me realize how crappy a programmer I am, algorithms-wise.
- streblo 18y agoThe interview process is definitely an intense one in this field. One thing to keep in mind when you're answering technical questions is that the interviewer is just as interested in hearing you think out the problem as they are in hearing the right answer. Thinking out loud is sometimes a good strategy if you run into a problem you can't answer on the spot.
- deleted 18y ago[deleted]
- plinkplonk 18y ago"Reading the technical questions made me realize how crappy a programmer I am, algorithms-wise" The good news is that this is very fixable. I could answer the questions in the article without effort but this is a very different situation from about 3 years ago when I wouldn't have been able to answer even one of these. I really started hitting the Algorithm books(Skiena, Cormen, if anyone is interested ) about three years ago and am now comfortable with thinking "algorithmically" - at least for sequential algorithms. Studying algorithms to a fair degree of competence is very feasible even for non CS folks - I have no degree in CS and am entirely self taught. The tough part was working through proofs - As I was reading about unit tests for the answers , either in the original article or the reddit comments, I forget which - I was thinking it might be better to write down a formal proof that the algorithm works. If I face tough questions on parallel/concurrent algorithm, I'd probably take a while to answer or fail completely - I need to look into parallel/concurrent algorithms in the coming year.
- deleted 18y ago[deleted]
- qqq 18y agoThis is hard to read because they specifically asked for a short line count, but it's not really very complicated. an if/else, a map, and a recursive call. Could maybe do the string manipulation more cleverly, but the obvious (assigning a new string to an index) is destructive in ruby. h = {'a' => ['A', '@', '4'], 'b' => ['B'], 'c' => ['C']} def foo str, h, pos=0 (pos>str.size-1) ? [str] : ([str[pos..pos]] + h[str[pos..pos]]).map {|new_char| foo(str[0...pos] + new_char + str[(pos+1)...(str.size)], h, pos+1) }.flatten end p foo('abc', h)