Given a string consisting of some numbers, not separated by any separator. The numbers are positive integers and the sequence increases by one at each… Read More

Given two numbers x and n, find a number of ways x can be expressed as sum of n-th power of unique natural numbers. Examples… Read More

Inheritance is an important pillar of OOP(Object-Oriented Programming). It is the mechanism in java by which one class is allowed to inherit the features(fields and… Read More

Java provides a wrapper class Boolean in java.lang package. The Boolean class wraps a value of the primitive type boolean in an object. An object… Read More

Given an array, we need to modify values of this array in such a way that sum of absolute differences between two consecutive elements is… Read More

Given an undirected connected tree with N nodes (and N-1 edges), we need to find two paths in this tree such that they are non-intersecting… Read More

Given an integer n. Check whether the number n is superperfect number or not. A superperfect number is a positive integer which satisfies σ2(n) =… Read More

DatagramSockets are Java’s mechanism for network communication via UDP instead of TCP. Java provides DatagramSocket to communicate over UDP instead of TCP. It is also… Read More

Given an array of numbers where every number is represented as string. The numbers may be very large (may not fit in long long int),… Read More

Given a string str that may contain one more occurrences of “AB”. Replace all occurrences of “AB” with “C” in str. Examples: Input : str… Read More

Given an array of integers. All numbers occur twice except one number which occurs once. Find the number in O(n) time & constant extra space.… Read More

Given a number, the task is to check if a number is divisible by 4 or not. The input number may be large and it… Read More

Although Java is strictly pass by value, the precise effect differs between whether a primitive type or a reference type is passed. When we pass… Read More

Prerequisite – Constructor, Overloading in java In addition to overloading methods, we can also overload constructors in java. Overloaded constructor is called based upon the… Read More

Given two integers n and k. Consider first permutation of natural n numbers, P = “1 2 3 … n”, print a permutation “Result” such… Read More