## Codility Passing Car Problem in Java

This is the Java Program to Solve the passing Car Codility Problem. Problem Description Given a boolean array of 0’s and 1’s, where 0’s represent cars going to east and 1’s represent cars going to the west. Find out the pairs of the cars that will cross each other, that is, the pairs of cars … Read more

## Dutch National Flag Problem in Java

This is the Java Program to Solve the Dutch National Flag Problem. Problem Description Given an array of 0’s, 1’s and 2’s, all the elements in the random order, sort the array in linear time, without using extra space. This is known as the Dutch National Flag problem. Example: Array = [1 0 2 2 … Read more

## Java Program to Replace Elements with Greatest Element on Right Side

This is the Java Program to Replace the Element with its Next Greatest Element, Rightmost Element will be Replaced by 0. Problem Description Given an array of integers, replace each element of the array with the greatest element present on the right side of the element, in the array. The rightmost element or the last … Read more

## Java Program to Find the Smallest Positive Number Missing from an Unsorted Array

This is the Java Program to Find the Smallest Positive Integer Missing in an Unsorted Integer Array. Problem Description Given an array of integers, find out the smallest positive integer missing from the array. Example: Array = [-1, -3, 3, 2, 8 ,6] Output: 1. Problem Solution First sort the array. Then initialize a variable … Read more

## Java Program to Find the Number Occurring Odd Number of Times

This is the Java Program to Print Elements Which Occur Odd Number of Times. Problem Description Given an array of integers, print all the elements whose frequency are odd. Example: Array = [5, 4, 4, 2, 1] Output: 5 2 1. Problem Solution Iterate through the array, and for every element, count its frequency in … Read more

## Java Program to Cyclically Permute the Elements of an Array

This is the Java Program to Cyclically Permute the Elements of an Array. Problem Description Given an array of integers, cyclically permute its elements, that is, shift each array element to the left by one index. The first value will go into the last index. Example: Array: [1,2,3,4,5] Output: [2,3,4,5,1] Problem Solution Store the first … Read more

## Java Program to Find the Frequency of All Duplicate Elements in an Array

This is the Java Program to Find Repeated Elements and the Frequency of Repetition. Problem Description Given an array of integers, find and print the repeated elements and their frequency of repetition. Example: Array: [1,2,3,4,5,5,3] Output: Element—–>Frequency 3—–>2 5—–>2 Problem Solution Sort the array, and find the frequency of each repeated element and print it. … Read more

## Java Program to Find the Address of an Array

This is the Java Program to Find Address of an Array Element Given the Base Address. Problem Description Given the base address of an array, and the element size. Find out the address of the given element. Example: Base address = 2400 Element Size = 5 Element index = 6 Output: Element address = 2430 … Read more

## Java Program to Find the Number Occurring Even Number of Times

This is the Java Program to Print Elements Which Occurs Even Number of Times. Problem Description Given an array of elements, print the elements whose frequency is even. Example: array = {5, 5, 2, 2, 2, 4, 4, 1, 7, 1} Output = 5 4 1 Problem Solution Create a separate array of boolean values … Read more 