Basic Array Problems

Complete collection of basic array problems from GeeksforGeeks

Progress0 / 60 completed
0%
#1

Largest Element in Array

Find the largest element in an array

InfosysOracleWiproMorgan Stanley
Time: O(n)Space: O(1)
Solve
#2

Second Largest Element

Find the second largest element in array

AmazonMicrosoft
Time: O(n)Space: O(1)
Solve
#3

Check if Array is Sorted

Check if array is sorted in ascending order

Amazon
Time: O(n)Space: O(1)
Solve
#4

Reverse an Array

Reverse the elements of an array

AmazonTCSCognizant
Time: O(n)Space: O(1)
Solve
#5

Remove Duplicates from Sorted Array

Remove duplicates from a sorted array

ZohoMicrosoftWipro
Time: O(n)Space: O(1)
Solve
#6

Move All Zeros to End

Move all zeros to the end while maintaining order

PaytmAmazonMicrosoft
Time: O(n)Space: O(1)
Solve
#7

Rotate Array

Rotate an array by K positions

AmazonMicrosoft
Time: O(n)Space: O(1)
Solve
#8

Find Missing Number

Find the missing number in array from 1 to N

AmazonMicrosoftAdobe
Time: O(n)Space: O(1)
Solve
#9

Count Frequency of Elements

Count frequency of each element in array

Amazon
Time: O(n)Space: O(n)
Solve
#10

Two Sum - Pair with Given Sum

Find if there exists a pair with given sum

AmazonGoogleMicrosoftFacebook
Time: O(n)Space: O(n)
Solve
#11

Array Subset of Another Array

Check if an array is subset of another array

AccoliteQualcomm
Time: O(n+m)Space: O(n)
Solve
#12

Union of Two Arrays

Find union of two arrays

Amazon
Time: O(m+n)Space: O(m+n)
Solve
#13

Intersection of Two Arrays

Find intersection of two arrays

FacebookAmazon
Time: O(m+n)Space: O(min(m,n))
Solve
#14

Find Duplicates in Array

Find all duplicate elements in array

AmazonSamsung
Time: O(n)Space: O(1)
Solve
#15

First Repeating Element

Find the first repeating element in array

AmazonOracle
Time: O(n)Space: O(n)
Solve
#16

Non-Repeating Element

Find the first non-repeating element

Zoho
Time: O(n)Space: O(n)
Solve
#17

Print Alternate Elements

Print alternate elements of an array

Time: O(n)Space: O(1)
Solve
#18

Sum of Array Elements

Find sum of all array elements

Wipro
Time: O(n)Space: O(1)
Solve
#19

Average in a Stream

Find average of stream of numbers

AmazonAdobe
Time: O(1)Space: O(1)
Solve
#20

Find Index

Find index of a given element

Time: O(n)Space: O(1)
Solve
#21

Value Equal to Index Value

Find elements where value equals its index

FlipkartAmazon
Time: O(n)Space: O(1)
Solve
#22

Smaller and Larger

Count elements smaller and larger than X

Time: O(n)Space: O(1)
Solve
#23

At Least Two Greater Elements

Find elements with at least two greater elements

Time: O(n log n)Space: O(1)
Solve
#24

Compete the Skills

Compare skills of two persons

Time: O(n)Space: O(1)
Solve
#25

Play with an Array

Perform operations on array elements

Time: O(n)Space: O(1)
Solve
#26

Palindromic Array

Check if all array elements are palindrome

Time: O(n*m)Space: O(1)
Solve
#27

Perfect Arrays

Check if array is perfect (reverse equals original)

Time: O(n)Space: O(1)
Solve
#28

Balanced Array

Check if array can be balanced

Time: O(n)Space: O(1)
Solve
#29

Fascinating Number

Check if number is fascinating

Time: O(1)Space: O(1)
Solve
#30

Product of Array Elements

Find product of all array elements

Time: O(n)Space: O(1)
Solve
#31

Cyclically Rotate Array by One

Rotate array by one position clockwise

Microsoft
Time: O(n)Space: O(1)
Solve
#32

Count Odd Even

Count odd and even elements in array

Time: O(n)Space: O(1)
Solve
#33

Find Minimum and Maximum

Find minimum and maximum element in array

MicrosoftWipro
Time: O(n)Space: O(1)
Solve
#34

Segregate 0s and 1s

Segregate 0s and 1s in array

Paytm
Time: O(n)Space: O(1)
Solve
#35

Sort Array of 0s, 1s and 2s

Sort an array containing only 0s, 1s and 2s

AmazonMicrosoftAdobePaytm
Time: O(n)Space: O(1)
Solve
#36

Binary Array Sorting

Sort binary array in-place

Infosys
Time: O(n)Space: O(1)
Solve
#37

Move Negative Elements to End

Move all negative elements to one side

PaytmAmazon
Time: O(n)Space: O(1)
Solve
#38

Kth Smallest Element

Find kth smallest element in array

AmazonMicrosoftCiscoVMWare
Time: O(n log n)Space: O(1)
Solve
#39

Kth Largest Element

Find kth largest element in array

AmazonCisco
Time: O(n log n)Space: O(1)
Solve
#40

Peak Element

Find a peak element in array

AmazonGoogleVisa
Time: O(log n)Space: O(1)
Solve
#41

Find Transition Point

Find point where 0s transition to 1s

Amazon
Time: O(log n)Space: O(1)
Solve
#42

First and Last Occurrences

Find first and last occurrences of x in sorted array

AmazonFlipkart
Time: O(log n)Space: O(1)
Solve
#43

Number of Occurrence

Count occurrences of a number in sorted array

ZohoAmazon
Time: O(log n)Space: O(1)
Solve
#44

Majority Element

Find element that appears more than n/2 times

AmazonMicrosoftGoogle
Time: O(n)Space: O(1)
Solve
#45

More than N/K Occurrences

Find elements appearing more than n/k times

Amazon
Time: O(n)Space: O(k)
Solve
#46

Find Element That Appears Once

Find element appearing once when others appear twice

AmazonMicrosoft
Time: O(n)Space: O(1)
Solve
#47

Search in Rotated Array

Search an element in rotated sorted array

AmazonMicrosoftAdobeSamsung
Time: O(log n)Space: O(1)
Solve
#48

Count Pairs with Given Sum

Count pairs of elements with given sum

AmazonAdobe
Time: O(n)Space: O(n)
Solve
#49

Find Common Elements

Find common elements in three sorted arrays

VMWareMicrosoft
Time: O(n1+n2+n3)Space: O(1)
Solve
#50

Rearrange Array Alternately

Rearrange array with max at first position, min at second

Zoho
Time: O(n)Space: O(1)
Solve
#51

Number of Pairs

Count pairs where x^y > y^x

AmazonMicrosoft
Time: O(n log n + m log n)Space: O(1)
Solve
#52

Inversion Count

Count inversions in array

AmazonMicrosoftAdobeMyntra
Time: O(n log n)Space: O(n)
Solve
#53

Leaders in Array

Find all elements greater than all elements to their right

Payu
Time: O(n)Space: O(n)
Solve
#54

Equilibrium Point

Find equilibrium point where left sum equals right sum

AmazonAdobe
Time: O(n)Space: O(1)
Solve
#55

Wave Array

Sort array in wave form

AmazonGoogle
Time: O(n)Space: O(1)
Solve
#56

Pythagorean Triplet

Check if array has Pythagorean triplet

AmazonMicrosoft
Time: O(n²)Space: O(1)
Solve
#57

Chocolate Distribution Problem

Minimize difference between maximum and minimum chocolates

FlipkartAmazon
Time: O(n log n)Space: O(1)
Solve
#58

Stock Buy and Sell

Find maximum profit by buying and selling stocks

AmazonMicrosoftFlipkartAdobeOracle
Time: O(n)Space: O(1)
Solve
#59

Element with Left Side Smaller

Find element with all left side smaller and right side greater

Amazon
Time: O(n)Space: O(n)
Solve
#60

Convert Array to Zig-Zag

Convert array to zig-zag fashion

AmazonPaytm
Time: O(n)Space: O(1)
Solve

Problem Statistics

Total Problems

60

Completed

0

Remaining

60

Progress

0%