Array

Level: Intermediate

1. Write a function to find the majority element in an array.
2. Implement a function to find the kth smallest element in an array.
3. Write a function to find the kth largest element in an array.
4. Implement a function to find the first repeating element in an array.
5. Write a function to find the first non-repeating element in an array.
6. Implement a function to find the subarray with the maximum sum.
7. Write a function to find the length of the longest subarray with a given sum.
8. Implement a function to find the number of subarrays with a given sum.
9. Write a function to find the maximum sum of a subarray of size k.
10. Implement a function to find the maximum sum of a circular subarray.
11. Write a function to find the maximum product of a subarray.
12. Implement a function to find the longest increasing subarray.
13. Write a function to find the longest decreasing subarray.
14. Implement a function to find the longest subarray with equal number of 0s and 1s.
15. Write a function to find the longest subarray with all distinct elements.
16. Implement a function to find the longest subarray with a given number of distinct elements.
17. Write a function to find the longest subarray with all elements having at most k distinct elements.
18. Implement a function to find the maximum length of a subarray with the sum of elements divisible by k.
19. Write a function to find the longest contiguous subarray with at least one 0.
20. Implement a function to find the length of the smallest subarray with a sum greater than or equal to a given value.
21. Write a function to find the longest subarray where the difference between the maximum and minimum elements is at most k.
22. Implement a function to find the maximum length of a subarray with the sum of elements equal to a given value.
23. Write a function to find the maximum length of a subarray with the product of elements equal to a given value.
24. Implement a function to find the longest subarray with a given sum and all elements are positive.
25. Write a function to find the longest subarray with a given sum and all elements are non-negative.
26. Implement a function to find the longest subarray with a given sum and all elements are negative.
27. Write a function to find the maximum length of a subarray with the product of elements equal to a given value.
28. Implement a function to find the maximum length of a subarray with the product of elements divisible by k.
29. Write a function to find the longest subarray with a given sum and all elements are distinct.
30. Implement a function to find the longest subarray with a given sum and all elements are same.

Beginner Level: View

Advanced Level: View