Skip to content

Commit 64239f4

Browse files
author
Toluwalase
committed
done with binary search tasks
1 parent 2891f39 commit 64239f4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def arrangeCoins(self, n: int) -> int:
3+
count = 0
4+
while count < n:
5+
count += 1
6+
n = n - count
7+
return count
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def searchInsert(self, nums: List[int], target: int) -> int:
3+
first = 0
4+
last = len(nums) - 1
5+
while first <= last:
6+
midpoint = (first+last)//2
7+
if nums[midpoint] == target:
8+
return midpoint
9+
elif nums[midpoint] < target:
10+
first = midpoint + 1
11+
else:
12+
last = midpoint - 1
13+
return first

0 commit comments

Comments
 (0)