Dude I just got selected for NVIDIA. It just happened that i follow you and it paid off big time !!! Thankyou ❤❤❤
@ceciljoel9577Сағат бұрын
What was the interview problem how would you rate it in terms of leetcode difficulty?
@VarunKumar-id6qvСағат бұрын
Medium problem but you have be good at explaining stuffs while coding
@ArcticFoxCodes20 сағат бұрын
Didn't want to take the time to code, but gave it some thought. Seems like the type of problem that one could come up with a fancy binary combinatorics solution or a dynamic programming solution. But, as I said, didn't care to take the time to work it out...
@彩色糖果-i4i20 сағат бұрын
From a Java user perspective, it looks like a list
@xingyuxiang1637Сағат бұрын
public class Solution { public List generateParenthesis(int n) { if (n left) { helper(left, right - 1, result, r +")"); } } } Greg's recursions are too advanced because you have a global variable and shared memory idea. They may be better for hard questions. This one is more like a dungeon-crawler game. You can find them on Leetcode, too.
@mohammedwissam268514 сағат бұрын
Way easier to solve it using dp.
@xingyuxiang163724 минут бұрын
ans = set() stack = [([], 0, 0)] # (state, left, right), where state is the list of parentheses while stack: state, left, right = stack.pop() if len(state) == 2*n and "".join(state) not in ans: ans.add("".join(state)) if left < n: state.append("(") stack.append((state.copy(), left+1, right)) state.pop() if right < left: # never add or ")" than existing "(" state.append(")") stack.append((state.copy(), left, right+1)) # state.pop() # not really needed-speeds up to omit return list(ans) This one is more like question 22 and also fits the order of drawing the tree. But still one needs to know how the stack mimics the tree. You can try a BFS algorithm or rework that as long as the right brackets are less than the left brackets, then keep branching. Of course, all these codes are on Leetcode, too. In short, recursions run backward.