# Array

## Iterating arrays with array.some() in JavaScript

When we start thinking of using an array, we think of iterations and other manipulations, and in JavaScript we often use the array.map() function to iterate through the array content. This post is about a special array method called array.some() that can be used to check if any one element… Read More »Iterating arrays with array.some() in JavaScript

## Majority Element in an Array – LeetCode

• DSA

Given an array of size n, find the majority element. The element that appears more than ⌊ n/2 ⌋ times in the array. Note: Input will be a non-empty and unsorted array. Example Solution Approach 1. Sorting On sorting the given array, the element occurring more than [n/2] times will… Read More »Majority Element in an Array – LeetCode

## Array of Structures – API Problem

• DSA

In this post we’ll be solving a simple problem using an Array of Structures. Problem Statement: Read an input of [N] API calls and find their Average, Each call has three timestamps [T1, T2, T3] and we need to give separate average for each. Example Output Explanation, in the above… Read More »Array of Structures – API Problem

## Even Odd Separation O(N) Single Iteration

• DSA

Given an array containing a mix of even and odd numbers, and we need to perform Even Odd Separation. In this post we’ll see how to separate even and odd numbers in a single iteration using two pointers. Example Solution Approach Method 1 To separate even-odd elements, we can take… Read More »Even Odd Separation O(N) Single Iteration

## Separate 0s and 1s – O(N) Single Iteration

• DSA

Given an array of numbers consisting of only zeroes and ones, and we need to separate 0s and 1s. This problem can be solved in many ways like sorting and performing basic swapping but I learned a method to do all of this in a single iteration. So, let’s do… Read More »Separate 0s and 1s – O(N) Single Iteration

## Perform Set Operations on Arrays

• DSA

In this problem, we’ll be performing some basic set operations on the given arrays like Union, Intersection, and Difference. I found this problem when I was writing a practice test on ADT (Array as a Data Structure). Examples Set Operations Union ∪ A union of two sets will contain the… Read More »Perform Set Operations on Arrays