Given an array count max number of surpassers

Problem For an array of integers, a surpasser of an integer element is an element on its right hand side that is larger than it. Given an array of integers, Output the max number of surpassers. Examples Example 1: Input: nums = [10, 3, 4, 5, 2] Output: 2 Explanation: The surpassers of 3 is 4 and 5, and 10 doesn’t have any surpasser. ...

Find fixed point in sorted array

Problem Given a sorted array of distinct integers, write a function to find the magic index or fixed point in the array, else return -1. Definition Magic index or a Fixed point in an array is an index i in the array A such that A[i] = i. Examples Example 1: Input: nums = [-6, 0, 2, 40] Output: 2 ...

Find smallest and second smallest elements in an array

Problem Given an array of integers, our task is to write a program that efficiently finds the smallest and second smallest element present in the array. This problem is similar to Find Second largest element in an array. Examples Example 1: Input: arr[] = {12, 13, 1, 10, 34, 1} Output: [1, 10] Explanation: 1 is smallest and 10 is second smallest ...

August 10, 2022 · 2 min · TagsList of tags for the post  array ·  array-algo
This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy