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

  1. Read the question carefully.
  2. Try the solution before checking the hint.
  3. Write and run the Python code.
  4. Test with small and large arrays.
  5. Improve your solution after reading the hint.

Practice Questions

  1. Print an Array
    Given an array of integers, print all elements separated by spaces.
  2. Largest Element
    Find the largest element in an array.
  3. Smallest Element
    Find the smallest element in an array.
  4. Sum of Elements
    Find the sum of all elements of an array.
  5. Average
    Calculate the average of all array elements.
  6. Count Even Numbers
    Count how many even numbers are present.
  7. Linear Search
    Search a given value using linear search.
  8. Reverse an Array
    Print the array in reverse order.
  9. Second Largest
    Find the second largest distinct element.
  10. Remove Duplicates
    Print only unique elements while preserving first occurrence.
  11. Frequency Count
    Print the frequency of every distinct element.
  12. Left Rotate by One
    Rotate the array one position to the left.
  13. Right Rotate by One
    Rotate the array one position to the right.
  14. Prefix Sum
    Generate the prefix sum array.
  15. Maximum Subarray Sum
    Find the maximum subarray sum using Kadane's Algorithm.

Answers / Hints

  1. Traverse the array once and print each element.
  2. Keep track of the maximum element while traversing.
  3. Keep track of the minimum element while traversing.
  4. Initialize sum = 0 and add every element.
  5. Average = Sum / Number of Elements.
  6. Increase the counter whenever element % 2 == 0.
  7. Compare every element until the value is found.
  8. Traverse from the last index to the first.
  9. Maintain both largest and second largest values during traversal.
  10. Use a set to remember visited elements while printing.
  11. Use a dictionary to count occurrences of each value.
  12. Store the first element, shift left, then place it at the end.
  13. Store the last element, shift right, then place it at the beginning.
  14. Each prefix value equals previous prefix plus current element.
  15. 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.