diff --git a/Sravani/9-10-22/Kth Missing Positive Number.py b/Sravani/9-10-22/Kth Missing Positive Number.py new file mode 100644 index 0000000..51fda6b --- /dev/null +++ b/Sravani/9-10-22/Kth Missing Positive Number.py @@ -0,0 +1,9 @@ +class Solution(object): + def findKthPositive(self, arr, k): + missing = [] + y = k+arr[-1] + for i in range(1,y+1): + if i not in arr: + missing.append(i) + return missing[k-1] + \ No newline at end of file diff --git a/Sravani/9-10-22/SEGM01.py b/Sravani/9-10-22/SEGM01.py new file mode 100644 index 0000000..b467414 --- /dev/null +++ b/Sravani/9-10-22/SEGM01.py @@ -0,0 +1,15 @@ +# cook your dish here +for i in range(int(input())): + num = input() + + x= num.count('1') + + flag = False + for i in range(0,len(num)): + if x!=0 and num[i:i+x]=='1'*x: + flag = True + if(flag): + print("YES") + else: + print("NO") + \ No newline at end of file diff --git a/Sravani/9-10-22/Search a 2D Matrix.py b/Sravani/9-10-22/Search a 2D Matrix.py new file mode 100644 index 0000000..78ee538 --- /dev/null +++ b/Sravani/9-10-22/Search a 2D Matrix.py @@ -0,0 +1,22 @@ +class Solution(object): + def searchMatrix(self, matrix, target): + nums = [j for sub in matrix for j in sub] + + low = 0 + high=len(nums)-1 + mid= 0 + output = 0 + while low <= high: + mid = (high + low) // 2 + if nums[mid] target: + high = mid - 1 + else: + output = True + break + + if(output): + return True + else: + return False \ No newline at end of file