Skip to content

Add implementation for leetcode problems from mock interview.#1170

Open
rishigoswamy wants to merge 1 commit intosuper30admin:masterfrom
rishigoswamy:master
Open

Add implementation for leetcode problems from mock interview.#1170
rishigoswamy wants to merge 1 commit intosuper30admin:masterfrom
rishigoswamy:master

Conversation

@rishigoswamy
Copy link

No description provided.

@super30admin
Copy link
Owner

Your solution for Pascal's Triangle is excellent. It is efficient, correct, and well-commented. The approach of initializing each row with 1s and then filling the middle values using the previous row is optimal. The code is clean and easy to understand.

One minor suggestion: In the Pascal's Triangle solution, you can consider adding a check for numRows=0 at the beginning to return an empty list, although the problem states that numRows is at least 1, so it's not strictly necessary.

For the K-diff Pairs solution, it is also correct and efficient. However, note that in the case k>0, you are iterating over all keys in the hashmap, which includes duplicates. But since you are using the keys (which are unique), it is correct. Alternatively, you could iterate over the unique keys by using a set, but your current approach is already efficient.

Overall, great job on both solutions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants