v1 - #1179
Conversation
super30admin
commented
Apr 29, 2026
Interview Problem : Pascal's Triangle (pascals-triangle.py)Your solution is correct for the given examples and has the right time and space complexity. However, there are a few areas where you can improve:
Here's a revised version of your code that addresses these points: classSolution:
defgenerate(self, numRows: int) ->List[List[int]]:
res= []
foriinrange(1, numRows+1):
row= [1] *iifi>2:
prevRow=res[-1]
forjinrange(1, i-1):
row[j] =prevRow[j-1] +prevRow[j]
res.append(row)
returnresThis version is cleaner and easier to read. VERDICT: PASS Interview Problem: Pairs with K difference (k-diff-pairs.py)Your solution is efficient and correct. You have used a Counter to count frequencies and then iterated over the unique numbers. For k != 0, you check if x + k exists in the counter, which ensures each pair is counted exactly once. For k=0, you check if the count is at least 2. This is a clean and efficient approach. Strengths:
Areas for improvement:
Overall, this is a very good solution. VERDICT: PASS |
No description provided.