11. Check if a String is a Palindrome
Required Input:
s = "madam"Expected Output:
True
Code In Python
def is_palindrome_string(s):
# Write your logic here
pass
# Prefilled input
s = "madam"
print(is_palindrome_string(s))
Run Code?
Click Run Button to view compiled output
12. Find the Middle of a Sorted Rotated Array
Required Input:
arr = [4, 5, 6, 7, 0, 1, 2]Expected Output:
7
Code In Python
def find_middle_rotated(arr):
# Write your logic here
pass
# Prefilled input
arr = [4, 5, 6, 7, 0, 1, 2]
print(find_middle_rotated(arr))
Run Code?
Click Run Button to view compiled output
13. Find Triplets That Sum to Zero
Required Input:
arr = [-1, 0, 1, 2, -1, -4]Expected Output:
[[-1, -1, 2], [-1, 0, 1]]
Code In Python
def three_sum(arr):
# Write your logic here
pass
# Prefilled input
arr = [-1, 0, 1, 2, -1, -4]
print(three_sum(arr))
Run Code?
Click Run Button to view compiled output
14. Find the Smallest Subarray with a Sum Greater Than a Given Value
Required Input:
arr = [2, 3, 1, 2, 4, 3], target = 7Expected Output:
2
Code In Python
def min_subarray_sum(arr, target):
# Write your logic here
pass
# Prefilled input
arr = [2, 3, 1, 2, 4, 3]
target = 7
print(min_subarray_sum(arr, target))
Run Code?
Click Run Button to view compiled output
15. Sort an Array with Only 0s, 1s, and 2s (Dutch National Flag Algorithm)
Required Input:
arr = [2, 0, 2, 1, 1, 0]Expected Output:
[0, 0, 1, 1, 2, 2]
Code In Python
def sort_colors(arr):
# Write your logic here
pass
# Prefilled input
arr = [2, 0, 2, 1, 1, 0]
print(sort_colors(arr))
Run Code?
Click Run Button to view compiled output
16. Find the Maximum Sum of a Subarray of Size K
Required Input:
arr = [2, 1, 5, 1, 3, 2], k = 3Expected Output:
9
Code In Python
def max_sum_subarray_k(arr, k):
# Write your logic here
pass
# Prefilled input
arr = [2, 1, 5, 1, 3, 2]
k = 3
print(max_sum_subarray_k(arr, k))
Run Code?
Click Run Button to view compiled output
17. Find the Longest Substring Without Repeating Characters
Required Input:
s = "abcabcbb"Expected Output:
3
Code In Python
def longest_unique_substring(s):
# Write your logic here
pass
# Prefilled input
s = "abcabcbb"
print(longest_unique_substring(s))
Run Code?
Click Run Button to view compiled output
18. Find Pairs with a Given Difference
Required Input:
arr = [1, 5, 3, 4, 2], k = 2Expected Output:
[[1, 3], [2, 4], [3, 5]]
Code In Python
def find_pairs_with_difference(arr, k):
# Write your logic here
pass
# Prefilled input
arr = [1, 5, 3, 4, 2]
k = 2
print(find_pairs_with_difference(arr, k))
Run Code?
Click Run Button to view compiled output
19. Find the Median of Two Sorted Arrays
Required Input:
arr1 = [1, 3], arr2 = [2]Expected Output:
2
Code In Python
def find_median_sorted_arrays(arr1, arr2):
# Write your logic here
pass
# Prefilled input
arr1 = [1, 3]
arr2 = [2]
print(find_median_sorted_arrays(arr1, arr2))
Run Code?
Click Run Button to view compiled output
20. Find the Minimum Difference Pair in Two Arrays
Required Input:
arr1 = [1, 4, 7, 10], arr2 = [2, 5, 8, 12]Expected Output:
[1, 2]
Code In Python
def min_difference_pair(arr1, arr2):
# Write your logic here
pass
# Prefilled input
arr1 = [1, 4, 7, 10]
arr2 = [2, 5, 8, 12]
print(min_difference_pair(arr1, arr2))
Run Code?
Click Run Button to view compiled output


