0% found this document useful (0 votes)
12 views2 pages

Array Questions Sample Outputs-1

The document presents a series of array practice questions along with sample inputs and outputs. It includes tasks such as finding the second largest element, rotating an array, identifying a missing number, moving zeros to the end, and finding duplicate elements. Each question is accompanied by a specific example to illustrate the expected result.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Array Questions Sample Outputs-1

The document presents a series of array practice questions along with sample inputs and outputs. It includes tasks such as finding the second largest element, rotating an array, identifying a missing number, moving zeros to the end, and finding duplicate elements. Each question is accompanied by a specific example to illustrate the expected result.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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]

You might also like