Given an array arr[] and an integer target, find the number of occurrences of target in the array. The implementation scans every element, so the input does not need to be sorted.
Given an array of n integers with duplicate, output unique numbers of the array.
Find the majority element in the array
Given an array array, find the majority element that appears more than half times in the array. If no majority exists, return -1.
Find minimum and maximum of an array
Given an array of numbers, find the minimum and maximum elements by scanning the array once.
Move negative to the beginning
An array has both positive and negative numbers in random order. Rearrange the array elements to move all negative numbers before all positive numbers.
Find the index of any peak element in a given array. A peak element is an element that is strictly greater than both of its immediate neighbors. The first and last elements of the array are considered to be adjacent to negative infinity. If multiple peaks exist, return the index of any one of them.
Given an array, reverse the order of its elements in place and return the reversed array.
Given an array, cyclically rotate the array left by one position. The first element moves to the end of the array.
Sort an array of 0s, 1s and 2s
Given an array arr[] consisting of only 0s, 1s, and 2s. Sort the array, i.e., put all 0s first, then all 1s and all 2s in last.
Given an array of integers arr, sort the array without using any built-in functions.