This repository contains my solutions to practice technical interview questions from top tech companies. I am using this challenge as an opportunity to improve my skills and work towards achieving my goals.
Question | Notes |
---|---|
Evaluate Reverse Polish Notation | it was a relatively easy question once you know the pattern behind it. it follows the classic stack pattern; appending the element till you find a operator. Once you find an operator, you have to pop the last two elements from the stack and perform the operation on the elements. Then add the result back to the stack. After you're done traversing, the first (0th) element of the stack would be the answer |
Combination sum III | so, yeah its basically a backtracking problem with you to find out your bounding function, pretty nuts right, lets digest its nutty behaviour. gym bros youll get a lot of protein with it.👀 So, under the hood it uses up some smart recursion, what i does is, it tries to traverse up each and every combination but smartly, i.e if it finds if its going out of nowhere, exceeding the limit of "k" elements or the target not reaching even if we have "k" elements then it backs off considering the path as beaten up. thats what we see in the base case of our recursive backtrack function. before the for loop. Well, so now we know when it needs to stop, lets go through what it does to actually have a walk, when we have the first element of the combination figured out with the num variable, it goes ahead and adds it to the temporary combination list and minuses the target (we want the target to be 0 eventually). we do this every time, i.e everytime we add a new element to our combination list. tho we keep in mind that we are only adding the element which is less, than our target, if we add it anyway, we end up increasing the sum and putting the target below, thats not helping and we dont want that. when we get a combination with the required "k" elements when we have our target 0, we add it to the result list and continue our search for more such combinations |