From d3b4de82b22de61cc3570d494efc1951a74a3f87 Mon Sep 17 00:00:00 2001 From: sreevardhan1099 Date: Thu, 15 Jan 2026 18:25:52 -0500 Subject: [PATCH] Completed Competitive_Coding-3 --- Problem-1.py | 38 ++++++++++++++++++++++++++++++++++++++ Problem-2.py | 27 +++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 Problem-1.py create mode 100644 Problem-2.py diff --git a/Problem-1.py b/Problem-1.py new file mode 100644 index 00000000..4f604be2 --- /dev/null +++ b/Problem-1.py @@ -0,0 +1,38 @@ +#Pascal's Triangle +# Time Complexity :O(n2) +# Space Complexity :O(1) +# Did this code successfully run on Leetcode :yes +# Any problem you faced while coding this :no + + +# Your code here along with comments explaining your approach +#start with first row of pascal triangle as [1] and then iterate through numsRows and keep adding arrays to result array by adding sum of the two numbers directly above and also parallely checking the two edges of each row +#time - O(n2) +#space - O(1) + +class Solution: + def generate(self, numRows: int) -> List[List[int]]: + result = [[]] + if(numRows==0): + return result + result = [[1]] + i=2 + while(i<=numRows): + p1=0 + p2=1 + curr=[] + j=0 + while(j int: + hashMap = Counter(nums) # frequency map + count=0 + for key, value in hashMap.items(): + if k==0: + if value>1: + count =count+1 + continue + if key+k in hashMap: + count=count+1 + return count + + + \ No newline at end of file