Skip to content

Array

Unique Pairs with Target Sum

Unique Pairs with Target Sum

🟢 Easy 🧩 Pattern – Arrays and Hashmap Given an array of distinct integers and a target sum, return an array of unique pairs of numbers which add up to the target sum. Each pair should be represented as an array containing only two numbers. Example Solution

Majority Element - 169

Majority Element – 169

🔗LC169 🟢 Easy 🧩 Pattern – Arrays and Hashmap Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example Solution

Separate 0s and 1s

Separate 0s and 1s in an array – Single Iteration

🟢 Easy 🧩 Pattern – Arrays Given an array which contains only zeroes and ones, we need to seperate them by putting the zeroes first followed by the ones. Example Solution The zeroPointer variable is used to keep track of the index where the next zero should be placed.