Array Practice Questions with Sample Outputs
1. Find the Second Largest Element in an Array (without sorting)
Sample Input:
Array: [10, 5, 20, 8, 15]
Sample Output:
Second Largest Element: 15
2. Rotate an Array Left by k Positions
Sample Input:
Array: [1, 2, 3, 4, 5]
k=2
Sample Output:
Rotated Array: [3, 4, 5, 1, 2]
3. Find the Missing Number in a List from 1 to n
Sample Input:
Array: [1, 2, 4, 5]
n=5
Sample Output:
Missing Number: 3
4. Move All Zeros to the End of an Array while Maintaining Order
Sample Input:
Array: [1, 0, 2, 0, 4, 0, 5]
Sample Output:
Array after moving zeros: [1, 2, 4, 5, 0, 0, 0]
5. Find Duplicate Elements in a List
Sample Input:
Array: [1, 2, 3, 4, 2, 5, 3]
Sample Output:
Duplicate Elements: [2, 3]