21. Square Root with Precision
Required Input:
50
3Expected Output:
7.071
Code In Python
def square_root_with_precision(x, precision):
# Write your logic here
pass
# Prefilled input
x = 50
precision = 3
print(square_root_with_precision(x, precision))
Run Code?
Click Run Button to view compiled output
22. Find in Infinite Array
Required Input:
[3, 5, 7, 9, 10, 13, 15, 18, 20, 25, 30]
18Expected Output:
7
Code In Python
def find_in_infinite_array(arr, target):
# Write your logic here
pass
arr = [3, 5, 7, 9, 10, 13, 15, 18, 20, 25, 30]
target = 18
print(find_in_infinite_array(arr, target))
Run Code?
Click Run Button to view compiled output
23. Aggressive Cows
Required Input:
[1, 2, 8, 4, 9]
3Expected Output:
3
Code In Python
def aggressive_cows(stalls, k):
# Write your logic here
pass
stalls = [1, 2, 8, 4, 9]
k = 3
print(aggressive_cows(stalls, k))
Run Code?
Click Run Button to view compiled output
24. Allocate Minimum Pages
Required Input:
[12, 34, 67, 90]
2Expected Output:
113
Code In Python
def allocate_pages(books, m):
# Write your logic here
pass
books = [12, 34, 67, 90]
m = 2
print(allocate_pages(books, m))
Run Code?
Click Run Button to view compiled output
25. Ship Packages in D Days
Required Input:
[1,2,3,4,5,6,7,8,9,10]
5
Expected Output:
15
Code In Python
def ship_within_days(weights, D):
# Write your logic here
pass
weights = [1,2,3,4,5,6,7,8,9,10]
D = 5
print(ship_within_days(weights, D))
Run Code?
Click Run Button to view compiled output
26. K-th Element in Two Sorted Arrays
Required Input:
[2, 3, 6, 7, 9]
[1, 4, 8, 10]
5
Expected Output:
6
Code In Python
def kth_element(arr1, arr2, k):
# Write your logic here
pass
arr1 = [2, 3, 6, 7, 9]
arr2 = [1, 4, 8, 10]
k = 5
print(kth_element(arr1, arr2, k))
Run Code?
Click Run Button to view compiled output
27. Minimum in Mountain Array
Required Input:
[10, 9, 8, 5, 3, 1]
Expected Output:
1
Code In Python
def find_min_mountain(arr):
# Write your logic here
pass
arr = [10, 9, 8, 5, 3, 1]
print(find_min_mountain(arr))
Run Code?
Click Run Button to view compiled output
28. Split Array Largest Sum
Required Input:
[7, 2, 5, 10, 8]
2
Expected Output:
18
Code In Python
def split_array(nums, m):
# Write your logic here
pass
arr = [7, 2, 5, 10, 8]
m = 2
print(split_array(arr, m))
Run Code?
Click Run Button to view compiled output
29. Count Target Occurrences
Required Input:
[1, 2, 2, 2, 3, 4]
2Expected Output:
3
Code In Python
def count_occurrences(arr, target):
# Write your logic here
pass
arr = [1, 2, 2, 2, 3, 4]
target = 2
print(count_occurrences(arr, target))
Run Code?
Click Run Button to view compiled output
30. Find Duplicate Number
Required Input:
[1, 3, 4, 2, 2]Expected Output:
2
Code In Python
def find_duplicate(arr):
# Write your logic here
pass
arr = [1, 3, 4, 2, 2]
print(find_duplicate(arr))
Run Code?
Click Run Button to view compiled output


