Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sravani/9-10-22/Kth Missing Positive Number.py
Original file line number Diff line number Diff line change
@@ -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]

15 changes: 15 additions & 0 deletions Sravani/9-10-22/SEGM01.py
Original file line number Diff line number Diff line change
@@ -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")

22 changes: 22 additions & 0 deletions Sravani/9-10-22/Search a 2D Matrix.py
Original file line number Diff line number Diff line change
@@ -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:
low = mid + 1
elif nums[mid] >target:
high = mid - 1
else:
output = True
break

if(output):
return True
else:
return False