Array - Data Structure

Array - Data Structure


  • Same or similar data type at contiguous memory locations.

  • Time Complexity:

    • Access -> at O(1).

    • Deletion at O(n).

    • Searching -> O(n)

    • Insertion -> O(n)

  • Types:

    • 1-dimensional

    • Multi-dimesional



For an array problem, these are the only approaches through which we can solve it.

  1. Iteration: In this approach, we can solve the problem by just iterating over the array or storing some information while iterating using some extra space like map, set etc and comes to a solution.


  1. Iteration after Sorting: In this technique, first we sort the array then iterate over it.


  1. Two Pointer: Here, we use 2 pointers I and j or Start and end. When we are using two pointers or how to decide whether these pointers from same side or opposite side, we have to make sure the behavior of both pointers must be opposite.

    Two Pointers from Opposite side


Untitled (1).png

Two Pointers from Same Side (Sliding Window)

eg: [](

![Untitled (2).png]( align="left")
  1. Prefix Sum : It is a technique which is used to solve many queries in constant time instead of linear time. And we can say it’s a form of Dynamic Programming.


So this is it for this article. I hope it helped you somewhere. Don't forget to support us and share with other geekians.

Thank you, Have a nice day !!