Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Interview Questions on Array
  • Practice Array
  • MCQs on Array
  • Tutorial on Array
  • Types of Arrays
  • Array Operations
  • Subarrays, Subsequences, Subsets
  • Reverse Array
  • Static Vs Arrays
  • Array Vs Linked List
  • Array | Range Queries
  • Advantages & Disadvantages
Open In App
Next Article:
String in Data Structure
Next article icon

Array Data Structure Guide

Last Updated : 13 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we introduce array, implementation in different popular languages, its basic operations and commonly seen problems / interview questions.

  • An array stores items (in case of C/C++ and Java Primitive Arrays) or their references (in case of Python, JS, Java Non-Primitive) at contiguous locations.
  • It offers mainly the following advantages over other data structures.
    Random Access : i-th item can be accessed in O(1) Time as we have the base address and every item or reference is of same size.
    Cache Friendliness : Since items / references are stored at contiguous locations, we get the advantage of locality of reference.
  • It is not useful in places where we have operations like insert in the middle, delete from middle and search in a unsorted data.
  • It is a fundamental and linear data structure using which we build other data structures like Stack Queue, Deque, Graph, Hash Table, etc.

Learn Basics of Array:

  • Introduction to Arrays
  • Applications of Array

Array in Different Language:

  • Arrays in C
  • Vector in C++ STL
  • Arrays in Java
  • ArrayList in Java
  • List in Python
  • Arrays in C#
  • Arrays in JavaScript

Basic Problems on Array:

  • Print Alternates
  • Linear Search
  • Largest Element
  • Second Largest
  • Largest Three
  • Leaders in an array
  • Check if Sorted
  • Remove Duplicates from Sorted
  • Generate all Subarrays
  • Reverse an Array
  • Rotate an Array
  • Zeroes to End
  • Min Increments to Make Equal
  • Min Cost to Make Size 1

Prerequisite for the Remaining Problems

  1. Binary Search
  2. Selection Sort, Insertion Sort, Binary Search, QuickSort, MergeSort, CycleSort, and HeapSort
  3. Sort in C++ / Sort in Java / Sort in Python / Sort in JavaScript
  4. Two Pointers Technique
  5. Prefix Sum Technique
  6. Basics of Hashing
  7. Window Sliding Technique

Easy Problems on Array:

  • Distinct Elements
  • Duplicate within K Distance
  • Make Even Positioned Greater
  • Sum of all Subarrays
  • Stock Buy and Sell – Multiple Transactions
  • Single Among Doubles
  • Missing Number
  • Missing and Repeating
  • Only Repeating from 1 to n-1
  • Sorted Subsequence of Size 3
  • Binary Sort
  • Stable Binary Sort
  • Stable Binary Sort with O(1) Space
  • Sort in Wave Form
  • Max Subarray Sum
  • K Concatenation Max Subarray Sum
  • Max Subarray Product
  • Equilibrium index
  • Two Sum - Find if there is a Pair
  • Two Sum - Closest Pair [More problems on 2 Sum in Medium Section]
  • Chocolate Distribution Problem
  • Union of two arrays
  • Intersection of two arrays
  • Union of two sorted arrays
  • Intersection of two sorted arrays

Medium Problems on Array:

  • Make arr[i] = i
  • Sort an array of 1 to n
  • Reorder according to given indexes
  • Minimum Swaps to Sort
  • Min in a Sorted Rotated
  • Max in a Sorted Rotated
  • Rotation Count in Rotated Sorted
  • Search in a Sorted Rotated
  • Nearly Sorted (or K sorted)
  • Product Except Self
  • K-th Largest Sum Subarray
  • Smallest missing number
  • Smallest subarray with sum greater than x
  • Inversion count
  • Merge Overlapping Intervals
  • Sort an array of 0s, 1s and 2s
  • Merge with O(1) extra space
  • Majority Element
  • Peak element
  • Count possible triangles
  • Sub-array with given sum
  • Longest Subarray with Equal 0s and 1s
  • Longest Common Span in Two Binary Arrays
  • Construct an array from its pair-sum array
  • 2 Sum - All Pairs
  • 2 Sum - Distinct Pairs
  • 3 Sum - Find Any
  • 3 Sum - Closest Triplet
  • 4 Sum - Find Any [More problems on 4 Sum in Hard Section]

Hard Problems on Array:

  • Surpasser Count
  • Trapping Rain Water
  • Top K Frequent Elements
  • Kth Missing Positive Number in a Sorted Array
  • Stock Buy and Sell - At Most K Transactions
  • Stock Buy and Sell - At Most 2 Transactions
  • Median in a Stream
  • Smallest Difference Triplet from 3 arrays
  • Max occurred in n ranges
  • 3 Sum - Distinct Triplets
  • 3 Sum - All Triplets
  • 4 Sum - Distinct Quadruples
  • 4 Sum - All Quadruples
  • 4 Sum - Closest Quadruple

Expert Problems for Competitive Programmers

  • MO’s Algorithm
  • Square Root (Sqrt) Decomposition Algorithm
  • Sparse Table
  • Range sum query using Sparse Table
  • Range Minimum Query (Square Root Decomposition and Sparse Table)
  • Range LCM Queries
  • Merge Sort Tree for Range Order Statistics
  • Minimum number of jumps to reach end
  • Space optimization using bit manipulations
  • Max value of Sum( i*arr[i]) with only rotations allowed

Quick Links :

  • ‘Practice Problems’ on Arrays
  • Top Array Interview Questions
  • ‘Quizzes’ on Arrays

Next Article
String in Data Structure

H

harendrakumar123
Improve
Article Tags :
  • DSA
  • Arrays
Practice Tags :
  • Arrays

Similar Reads

  • DSA Tutorial - Learn Data Structures and Algorithms
    DSA (Data Structures and Algorithms) is the study of organizing data efficiently using data structures like arrays, stacks, and trees, paired with step-by-step procedures (or algorithms) to solve problems effectively. Data structures manage how data is stored and accessed, while algorithms focus on
    7 min read
  • Array Data Structure Guide
    In this article, we introduce array, implementation in different popular languages, its basic operations and commonly seen problems / interview questions. An array stores items (in case of C/C++ and Java Primitive Arrays) or their references (in case of Python, JS, Java Non-Primitive) at contiguous
    4 min read
  • String in Data Structure
    A string is a sequence of characters. The following facts make string an interesting data structure. Small set of elements. Unlike normal array, strings typically have smaller set of items. For example, lowercase English alphabet has only 26 characters. ASCII has only 256 characters.Strings are immu
    3 min read
  • Matrix Data Structure
    Matrix Data Structure is a two-dimensional array arranged in rows and columns. It is commonly used to represent mathematical matrices and is fundamental in various fields like mathematics, computer graphics, and data processing. Matrices allow for efficient storage and manipulation of data in a stru
    2 min read
  • Searching Algorithms
    Searching algorithms are essential tools in computer science used to locate specific items within a collection of data. In this tutorial, we are mainly going to focus upon searching in an array. When we search an item in an array, there are two most common algorithms used based on the type of input
    3 min read
  • Sorting Algorithms
    A Sorting Algorithm is used to rearrange a given array or list of elements in an order. For example, a given array [10, 20, 5, 2] becomes [2, 5, 10, 20] after sorting in increasing order and becomes [20, 10, 5, 2] after sorting in decreasing order. There exist different sorting algorithms for differ
    3 min read
  • Hashing in Data Structure
    Hashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access. Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function. It enables fast retrieval of information based on its key. The
    3 min read
  • Two Pointers Technique
    Two pointers is really an easy and effective technique that is typically used for Two Sum in Sorted Arrays, Closest Two Sum, Three Sum, Four Sum, Trapping Rain Water and many other popular interview questions. Given a sorted array arr (sorted in ascending order) and a target, find if there exists an
    12 min read
  • Sliding Window Technique
    Sliding Window problems involve moving a fixed or variable-size window through a data structure, typically an array or string, to solve problems efficiently based on continuous subsets of elements. This technique is used when we need to find subarrays or substrings according to a given set of condit
    15+ min read
  • Prefix Sum Array - Implementation and Applications
    Given an array arr[] of size n, the task is to find the prefix sum of the array. A prefix sum array is another array prefixSum[] of the same size, such that prefixSum[i] is arr[0] + arr[1] + arr[2] . . . arr[i]. Examples: Input: arr[] = [10, 20, 10, 5, 15]Output: 10 30 40 45 60Explanation: For each
    8 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences