Java Program to Find closest number in array
Given an array of sorted integers. We need to find the closest value to the given number. Array may contain duplicate values and negative numbers....
read more
Classification of Algorithms with Examples
There are many ways of classifying algorithms and a few of them are shown below:...
read more
Search for an element in a Mountain Array
Given a mountain array arr[] and an integer X, the task is to find the smallest index of X in the given array. If no such index is found, print -1....
read more
How to implement text Auto-complete feature using Ternary Search Tree
Given a set of strings S and a string patt the task is to autocomplete the string patt to strings from S that have patt as a prefix, using a Ternary Search Tree. If no string matches the given prefix, print “None”.Examples:...
read more
Check if a given number is a Perfect square using Binary Search
Check if a given number N is a perfect square or not. If yes then return the number of which it is a perfect square, Else print -1....
read more
Kth smallest element in the array using constant space when array can’t be modified
Given an array arr[] of size N having no duplicates and an integer K, the task is to find the Kth smallest element from the array in constant extra space and the array can’t be modified....
read more
Count the triplets such that A[i] < B[j] < C[k]
Given three array A[], B[] and C[] of N integers each. The task is to find the count of triplets (A[i], B[j], C[k]) such that A[i] < B[j] < C[k]....
read more
Find element position in given monotonic sequence
Given an integer k and a monotonic increasing sequence: f(n) = an + bn [log2(n)] + cn^3 where (a = 1, 2, 3, …), (b = 1, 2, 3, …), (c = 0, 1, 2, 3, …) Here, [log2(n)] means, taking the log to the base 2 and round the value down Thus, if n = 1, the value is 0. if n = 2-3, the value is 1. if n = 4-7, the value is 2. if n = 8-15, the value is 3. The task is to find the value n such that f(n) = k, if k doesn’t belong to the sequence then print 0....
read more
Number of days after which tank will become empty
Given a tank with capacity C liters which is completely filled in starting. Everyday tank is filled with l liters of water and in the case of overflow extra water is thrown out. Now on i-th day i liters of water is taken out for drinking. We need to find out the day at which tank will become empty the first time....
read more
Python3 Program to Print all triplets in sorted array that form AP
Given a sorted array of distinct positive integers, print all triplets that form AP (or Arithmetic Progression)Examples :...
read more
Java Program for Number of unique triplets whose XOR is zero
Given N numbers with no duplicates, count the number of unique triplets (ai, aj, ak) such that their XOR is 0. A triplet is said to be unique if all of the three numbers in the triplet are unique....
read more
Python3 Program for Number of unique triplets whose XOR is zero
Given N numbers with no duplicates, count the number of unique triplets (ai, aj, ak) such that their XOR is 0. A triplet is said to be unique if all of the three numbers in the triplet are unique....
read more