Saturday Questions
27-06-2026 | DSA Arrays in Python
Professional weekly coding practice by Programmer's Picnic
About This Set
This week's Saturday Questions focuses on Arrays, one of the most important topics in Data Structures and Algorithms (DSA). The questions move from simple traversal to searching, frequency counting, rotation, prefix sum, and Kadane's Algorithm.
How to Practice
- Read the question carefully.
- Try the solution before checking the hint.
- Write and run the Python code.
- Test with small and large arrays.
- Improve your solution after reading the hint.
Practice Questions
- Print an Array
Given an array of integers, print all elements separated by spaces. - Largest Element
Find the largest element in an array. - Smallest Element
Find the smallest element in an array. - Sum of Elements
Find the sum of all elements of an array. - Average
Calculate the average of all array elements. - Count Even Numbers
Count how many even numbers are present. - Linear Search
Search a given value using linear search. - Reverse an Array
Print the array in reverse order. - Second Largest
Find the second largest distinct element. - Remove Duplicates
Print only unique elements while preserving first occurrence. - Frequency Count
Print the frequency of every distinct element. - Left Rotate by One
Rotate the array one position to the left. - Right Rotate by One
Rotate the array one position to the right. - Prefix Sum
Generate the prefix sum array. - Maximum Subarray Sum
Find the maximum subarray sum using Kadane's Algorithm.
Answers / Hints
- Traverse the array once and print each element.
- Keep track of the maximum element while traversing.
- Keep track of the minimum element while traversing.
- Initialize
sum = 0and add every element. - Average = Sum / Number of Elements.
- Increase the counter whenever
element % 2 == 0. - Compare every element until the value is found.
- Traverse from the last index to the first.
- Maintain both largest and second largest values during traversal.
- Use a set to remember visited elements while printing.
- Use a dictionary to count occurrences of each value.
- Store the first element, shift left, then place it at the end.
- Store the last element, shift right, then place it at the beginning.
- Each prefix value equals previous prefix plus current element.
- Kadane's Algorithm maintains current maximum and global maximum.
Difficulty
Easy: Questions 1 to 8
Medium: Questions 9 to 15
Programmer's Picnic
DSA Practice by Champak Roy
Learn clearly. Practice regularly. Build strong programming skills.