From 0fd63084f09c28e5298ba99899350195b9de83cd Mon Sep 17 00:00:00 2001 From: pujab21 <94778475+pujab21@users.noreply.github.com> Date: Tue, 31 May 2022 19:47:23 +0530 Subject: [PATCH 1/7] Day 5s POD by puja --- POD/week1-arrays/day5_2.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 POD/week1-arrays/day5_2.py diff --git a/POD/week1-arrays/day5_2.py b/POD/week1-arrays/day5_2.py new file mode 100644 index 0000000..2a02240 --- /dev/null +++ b/POD/week1-arrays/day5_2.py @@ -0,0 +1,19 @@ +t = int(input()) +for _ in range(t): + n = int(input()) + l = list(map(int,input().split())) + c = 0 + #finding the bigger of the first and second element + p = max(l[:1]) + for i in range(n): + #condition for record breaking: + #index 0: day 1 visitors is more than day 2 + #day 2 to day n-1(day i): visitors is max of the subarray [0:i], and visitors on day i is more than i+1 + #day n(last day) (index n-1):visitors is max of the full array + if (i == 0 or l[i] > p) and (i == n-1 or l[i]> l[i+1]): + c+=1 + #updating the maximum no of visitors from the subarray[0:i] + if l[i]>p: + p = l[i] + + print("Case #{}: {}".format(_+1,c)) From 1de001949596e110502a0a00f62942a0f358f662 Mon Sep 17 00:00:00 2001 From: pujab21 <94778475+pujab21@users.noreply.github.com> Date: Tue, 31 May 2022 19:58:45 +0530 Subject: [PATCH 2/7] Create day4.py --- POD/week1-arrays/day4.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 POD/week1-arrays/day4.py diff --git a/POD/week1-arrays/day4.py b/POD/week1-arrays/day4.py new file mode 100644 index 0000000..ab5c6f4 --- /dev/null +++ b/POD/week1-arrays/day4.py @@ -0,0 +1,26 @@ + +for _ in range(int(input())): + n,s = map(int,input().split()) + arr = list(map(int,input().split())) + #before start setting the indices of the subarray + i0,j0=-1,-1 + for i in range(n): + #setting sum as the first element of the subarray + su = arr[i] + try: + #checking for an index j so that sum of arr[i:j] is the req sum + for j in range(i+1,n): + su += arr[j] + #if the sum is required sum set the indices of i and j + if su == s: + i0 = i + j0 = j + break + + except: + pass + if j0!= -1: + print(i0+1,j0+1) + break + else: + print(-1) From 8655d9d1134c2810f1d9c5a722986a8b319f2fd7 Mon Sep 17 00:00:00 2001 From: pujab21 <94778475+pujab21@users.noreply.github.com> Date: Tue, 31 May 2022 21:08:18 +0530 Subject: [PATCH 3/7] Create week2day1.py --- POD/week2day1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 POD/week2day1.py diff --git a/POD/week2day1.py b/POD/week2day1.py new file mode 100644 index 0000000..60c5a9b --- /dev/null +++ b/POD/week2day1.py @@ -0,0 +1,18 @@ +def isomorphic(s,t): + if len(s)!=len(t): + return False + #creating a one-on-one mapping + d1 = {} + d2 = {} + for i in range(len(s)): + if s[i] not in d1 and t[i] not in d2: + #if they are not there add new one on one mapping + d1[s[i]] = t[i]; + d2[t[i]] = s[i]; + else: + #check that it is the same mapping + if d1[s[i]] != t[i] or d2[t[i]] != s[i]: + return False + return True + +print(isomorphic(input(),input())) From 9fabb37ad70b83a0854d3f29e2e15564f983f818 Mon Sep 17 00:00:00 2001 From: pujab21 <94778475+pujab21@users.noreply.github.com> Date: Tue, 31 May 2022 21:08:59 +0530 Subject: [PATCH 4/7] Delete week2day1.py --- POD/week2day1.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 POD/week2day1.py diff --git a/POD/week2day1.py b/POD/week2day1.py deleted file mode 100644 index 60c5a9b..0000000 --- a/POD/week2day1.py +++ /dev/null @@ -1,18 +0,0 @@ -def isomorphic(s,t): - if len(s)!=len(t): - return False - #creating a one-on-one mapping - d1 = {} - d2 = {} - for i in range(len(s)): - if s[i] not in d1 and t[i] not in d2: - #if they are not there add new one on one mapping - d1[s[i]] = t[i]; - d2[t[i]] = s[i]; - else: - #check that it is the same mapping - if d1[s[i]] != t[i] or d2[t[i]] != s[i]: - return False - return True - -print(isomorphic(input(),input())) From af2611862b11a013f897ea28485818d6daebd861 Mon Sep 17 00:00:00 2001 From: pujab21 <94778475+pujab21@users.noreply.github.com> Date: Tue, 31 May 2022 21:11:36 +0530 Subject: [PATCH 5/7] Create day1.py --- POD/Week 2/day1.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 POD/Week 2/day1.py diff --git a/POD/Week 2/day1.py b/POD/Week 2/day1.py new file mode 100644 index 0000000..43f9f8e --- /dev/null +++ b/POD/Week 2/day1.py @@ -0,0 +1,19 @@ +def isomorphic(s,t): + if len(s)!=len(t): + return False + #dictionaries to store 1-on-1 mappings + d1 = {} + d2 = {} + for i in range(len(s)): + #check if mapping between either s[i] or t[i] exists + if s[i] not in d1 and t[i] not in d2: + #create the mapping + d1[s[i]] = t[i]; + d2[t[i]] = s[i]; + else: + #check if the already existing mapping matches current one + if d1[s[i]] != t[i] or d2[t[i]] != s[i]: + return False + return True + +print(isomorphic(input(),input())) From 18adec2f4c967fb778096b9bdc1d9b7be1157cfe Mon Sep 17 00:00:00 2001 From: pujab21 <94778475+pujab21@users.noreply.github.com> Date: Tue, 31 May 2022 21:18:50 +0530 Subject: [PATCH 6/7] Create day1_puja.py --- POD/Week 2/day1_puja.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 POD/Week 2/day1_puja.py diff --git a/POD/Week 2/day1_puja.py b/POD/Week 2/day1_puja.py new file mode 100644 index 0000000..fd43bb2 --- /dev/null +++ b/POD/Week 2/day1_puja.py @@ -0,0 +1,16 @@ + +def isomorphic(s,t): + if len(s)!=len(t): + return False + d1 = {} + d2 = {} + for i in range(len(s)): + if s[i] not in d1 and t[i] not in d2: + d1[s[i]] = t[i]; + d2[t[i]] = s[i]; + else: + if d1[s[i]] != t[i] or d2[t[i]] != s[i]: + return False + return True + +print(isomorphic(input(),input())) From 01f7f68dbd60298b6555653399c9f9b69702d8c7 Mon Sep 17 00:00:00 2001 From: pujab21 <94778475+pujab21@users.noreply.github.com> Date: Tue, 31 May 2022 21:19:06 +0530 Subject: [PATCH 7/7] Rename day1.py to day2.py --- POD/Week 2/{day1.py => day2.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename POD/Week 2/{day1.py => day2.py} (100%) diff --git a/POD/Week 2/day1.py b/POD/Week 2/day2.py similarity index 100% rename from POD/Week 2/day1.py rename to POD/Week 2/day2.py