c++
Find k closest elements to a given value in an array
Given a sorted integer array, find the k closest elements to x in the array where k and x are given positive integers. The integer x may or may not be present in the input Read more…
Given a sorted integer array, find the k closest elements to x in the array where k and x are given positive integers. The integer x may or may not be present in the input Read more…
Suppose you are given n red and n blue water jugs, all of different shapes and sizes. All red jugs hold different amounts of water, as do the blue ones. Moreover, there is a blue Read more…
Given an m-ary tree, write an efficient algorithm to convert the tree to its mirror. An m-ary tree (aka k-ary tree) is a tree in which each node has no more than m children. Each Read more…
Given an array of integers, trim it such that its maximum element becomes less than twice the minimum, return the minimum number of removals required for the conversion. For example, The idea is straightforward and Read more…
Given an undirected graph, check whether it has an Eulerian path or not. In other words, check if it is possible to construct a path that visits each edge exactly once. An Eulerian trail is Read more…
Given an array of integers, find the next greater element for every element in the array. The next greater element of a number x is the first greater number to the right of x in Read more…
Hello Program in Java The Hello program in Java displays the word Hello on the console. It is the basic program in Java. In this section, we will learn different ways to create and display the word Hello on the console. Read more…
The LCM program in Java outputs the LCM of the given numbers. In Arithmetic, the lowest common multiple, least common multiple or smallest common multiple of the two numbers p and q are represented by LCM(p, q). It Read more…