Complete competitive-coding-3 - #1177
Conversation
super30admin
commented
Apr 14, 2026
Interview Problem : Pascal's Triangle (PascalsTriangle.swift)Your solution is correct and handles the problem as required. Here are some suggestions for improvement:
Here's a revised version of your code for reference: func generate(_ numRows:Int)->[[Int]]{guard numRows >0else{return[]}varresult=[[1]]foriin1..<numRows {varrow=[1]letprevRow=result[i-1]forjin1..<i {
row.append(prevRow[j-1]+ prevRow[j])}
row.append(1)
result.append(row)}return result
}This version is more streamlined and handles all rows uniformly. VERDICT: PASS Interview Problem: Pairs with K difference (PairsWithKDiff.swift)Your solution However, your first solution For the problem constraints, the map-based solution is preferable because it is straightforward and avoids potential issues with ordering during traversal. I recommend using the VERDICT: PASS |
-> Pascal's triange
-> Pairs with k difference