11. Search in Rotated Array
Required Input:
[4,5,6,7,0,1,2]
6Expected Output:
2
Code In Python
def search_rotated_array(arr, target):
# Write your logic here
pass
# Prefilled input
arr = [4, 5, 6, 7, 0, 1, 2]
target = 6
print(search_rotated_array(arr, target))
Run Code?
Click Run Button to view compiled output
12. K Closest Elements
Required Input:
[1,2,3,4,5]
2
3Expected Output:
[2, 3]
Code In Python
def k_closest_elements(arr, k, target):
# Write your logic here
pass
# Prefilled input
arr = [1, 2, 3, 4, 5]
k = 2
target = 3
print(k_closest_elements(arr, k, target))
Run Code?
Click Run Button to view compiled output
13. Missing in AP
Required Input:
[2, 4, 8, 10, 12]Expected Output:
6
Code In Python
def missing_ap_term(arr):
# Write your logic here
pass
# Prefilled input
arr = [2, 4, 8, 10, 12]
print(missing_ap_term(arr))
Run Code?
Click Run Button to view compiled output
14. Peak in Unsorted
Required Input:
[1,3,20,4,1,0]Expected Output:
20
Code In Python
def find_peak_unsorted(arr):
# Write your logic here
pass
# Prefilled input
arr = [1, 3, 20, 4, 1, 0]
print(find_peak_unsorted(arr))
Run Code?
Click Run Button to view compiled output
15. K-th Smallest Element
Required Input:
[7,10,4,3,20,15]
3Expected Output:
7
Code In Python
def kth_smallest_element(arr, k):
# Write your logic here
pass
# Prefilled input
arr = [7, 10, 4, 3, 20, 15]
k = 3
print(kth_smallest_element(arr, k))
Run Code?
Click Run Button to view compiled output
16. Nearly Sorted Search
Required Input:
[10,3,40,20,50,80,70]
40Expected Output:
2
Code In Python
def search_nearly_sorted(arr, target):
# Write your logic here
pass
# Prefilled input
arr = [10, 3, 40, 20, 50, 80, 70]
target = 40
print(search_nearly_sorted(arr, target))
Run Code?
Click Run Button to view compiled output
17. Median of Two Arrays
Required Input:
[1,3]
[2]Expected Output:
2
Code In Python
def find_median_sorted_arrays(nums1, nums2):
# Write your logic here
pass
# Prefilled input
nums1 = [1, 3]
nums2 = [2]
print(find_median_sorted_arrays(nums1, nums2))
Run Code?
Click Run Button to view compiled output
18. Smallest Missing Positive
Required Input:
[3,4,-1,1]Expected Output:
2
Code In Python
def find_smallest_missing_positive(arr):
# Write your logic here
pass
# Prefilled input
arr = [3, 4, -1, 1]
print(find_smallest_missing_positive(arr))
Run Code?
Click Run Button to view compiled output
19. K-th Smallest Pair Distance
Required Input:
[1,3,1]
k = 1Expected Output:
0
Code In Python
def kth_smallest_pair_distance(arr, k):
# Write your logic here
pass
# Prefilled input
arr = [1, 3, 1]
k = 1
print(kth_smallest_pair_distance(arr, k))
Run Code?
Click Run Button to view compiled output
20. K-th Missing Positive
Required Input:
[2,3,4,7,11]
5Expected Output:
9
Code In Python
def kth_missing_positive(arr, k):
# Write your logic here
pass
# Prefilled input
arr = [2, 3, 4, 7, 11]
k = 5
print(kth_missing_positive(arr, k))
Run Code?
Click Run Button to view compiled output


