This example will show you how to segregate positive followed by negative elements in an Array using Java programming language. The function will put all positive numbers first, and then negative numbers and finally count the number of moves required to arrange all elements in the desired order. Prerequisite Knowledge of Java Let’s move on […]
Here we will find out minimum moves to equalize array elements. We will check the equality of elements from two arrays. As a pre-condition both arrays must have equal number of elements, i.e., in other words both arrays must be of same length. We will read each element from both arrays one by one at […]
This tutorial will find out minimum moves to segregate even followed by odd elements in Array using Java programming language. The function will put all even numbers first, and then odd numbers and finally count the number of moves required to arrange all elements in the desired order.
This tutorial will show you how to return array of products of all other numbers from a given array. Let’s say you are given an array of non-zero integers. So you have to return an output array of products of all other numbers except the number itself.
Finding start and end index of an element in a sorted array using Kotlin programming language will be shown here. The array may contain duplicate elements and we will see how to find a start and end index for an element in this array elements. We may design the algorithm for finding start and end […]
This tutorial will show you Hackerrank 1D Array Part 2 using Kotlin. Let’s play a game on an array! You’re standing at index 0 of an n-element array named game. From some index i (where 0 <= i < n), you can perform one of the following moves: Move Backward: If cell i-1 exists and […]
This tutorial will show you how to solve HackerRank Subarray using Kotlin. A subarray of an n-element array is an array composed from a contiguous block of the original array’s elements. For example, if array=[1,2,3], then the subarrays are , , , [1,2], [2,3], and [1,2,3]. Something like [1,3] would not be a subarray as […]
This examples shows how to move all non-zero elements(if any) in an array to the left and all zero elements to the right in the array using Java.