Featured Article

Longest common subsequence with permutations allowed

Given two strings in lowercase, find the longest string whose permutations are subsequences of given two strings. The output longest string must be sorted. Examples: Input : str1 = “pink”, str2 = “kite” Output : “ik” The string “ik” is the longest sorted string whose one permutation “ik” is subsequence of “pink” and another permutation… Read More »

Featured Article

Count ways to spell a number with repeated digits

Given a string that contains digits of a number. The number may contain many same continuous digits in it. The task is to count number of ways to spell the number. For example, consider 8884441100, one can spell it simply as triple eight triple four double two and double zero. One can also spell as… Read More »

Featured Article

How JVM Works – JVM Architecture?

JVM(Java Virtual Machine) acts as a run-time engine to run Java applications. JVM is the one that actually calls the main method present in a java code. JVM is a part of JRE(Java Run Environment). Java applications are called WORA (Write Once Run Everywhere). This means a programmer can develop Java code on one system… Read More »

Equal Sum and XOR

Given a positive integer n, find count of positive integers i such that 0 <= i <= n and n+i = n^i Input : n = 7 Output : 1 Explanation: 7^i = 7+i holds only for only for i = 0 7+0 = 7^0 = 7 Input : n = 12 Output : 4… Read More »

LinkedHashMap class in Java with Example

HashMap in Java provides quick insert, search and delete operations. However it does not maintain any order on elements inserted into it. If we want to keep track of order of insertion, we can use LinkedHashMap. LinkedHashMap is like HashMap with additional feature that we can access elements in their insertion order. Syntax LinkedHashMap<Integer, String>… Read More »

Perfect reversible string

You are given a string ‘str’, the task is to check that reverses of all possible substrings of ‘str’ are present in ‘str’ or not. Input : str = “ab” Output: “NO” // all substrings are “a”,”b”,”ab” but reverse // of “ab” is not present in str Input : str = “aba” Output: “YES” Input… Read More »

Arrays.deepToString() in Java with Example

java.util.Arrays.deepToString(Object[]) method is a java.util.Arrays class method. Returns a string representation of the “deep contents” of the specified array. If the array contains other arrays as elements, the string representation contains their contents and so on. This method is designed for converting multidimensional arrays to strings. The simple toString() method works well for simple arrays,… Read More »

String to Integer in Java – parseInt()

While operating upon strings, there are times when we need to convert a number represented as a string into an integer type. The method generally used is parseInt(). How to use parseInt() method in Java? There are two variants of this method: public static int parseInt(String s) throws NumberFormatException – This function parses the string… Read More »

MakeMyTrip Interview Experience | Set 13 (On-Campus for Full Time)

I recently got interviewed for MakeMyTrip for the Software Engineer full time position. There were in a total of 5 rounds. First Round (Online Coding + Aptitude): Firstly don’t expect the online interface to be friendly. There were 3 sections. First section was aptitude which had very very simple questions like addition, subtraction. Second section… Read More »

CountDownLatch in Java

CountDownLatch is used to make sure that a task waits for other threads before it starts. To understand its application, let us consider a server where the main task can only start when all the required services have started. Working of CountDownLatch: When we create an object of CountDownLatch, we specify the number if threads… Read More »