Given an array consisting of only 1s and 0s, sort this binary array such that all 0s are on the left and all 1s are on the right.
Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in the array.
Given an integer range, for all M in that inclusive range, determine the minimum (abs(arr[i]-M) for all
1 <= i <= size[a]
Challenge is to find an element of the array such that the sum of all elements to the left is equal to the sum of all elements to the right
Given a list of integers, arr, and a single integer k. Create an array of size k from elements of arr such that its unfairness is minimum
Problem Given an array A of length N, your task is to find the element which repeats in A maximum number of times as well as the corresponding count. In case of ties, choose the smaller element first. Codechef Problem Link Input First line of input contains an integer T, denoting […]
Jump game (Leetcode) problem statement:You are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise. Jump game – Leetcode Example 1: Input: nums = [2,3,1,1,4] Output: […]
Problem Statement [LeetCode]You are given an array prices where prices[i] is the price of a given stock on the ith day. You need to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve […]
Problem Statement Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one. Example 1: Input: nums = [-10,-3,0,5,9] Output: [0,-3,9,-10,null,5] Approach This problem […]
Array rotation is a problem of changing the order of the elements of the array. Increasing the index of the element by one and changing the index of the last element to 0 and so on. Problem Statement: Given an array arr of size n, rotate it by d elements. Example […]