Amazon Interview experience | Set 331 (1 Year Experienced for SE-1)

A big big thanks to geeks for geeks for constructing this platform where candidates find suitable question sets. 1. 1st Round (Coding round on hacker rank) : Two questions. Each of 100 marks. Total time given was 2 hours. Question 1: Question 2: 2. 2nd Round (Tech) : Two questions. Here the basic… Read More »

Make largest palindrome by changing at most K-digits

Given a string containing all digits, we need to convert this string to a palindrome by changing at most K digits. If many solutions are possible then print lexicographically largest one. Examples: Input : str = “43435” k = 3 Output : “93939” Lexicographically largest palindrome after 3 changes is “93939” Input : str =… Read More »

Count of total anagram substrings

Given a string of lower alphabet characters, count total substring of this string which are anagram to each other. Examples: Input : str = “xyyx” Output : 4 Total substrings of this string which are anagram to each other are 4 which can be enumerated as, {“x”, “x”}, {“y”, “y”}, {“xy”, “yx”}, {“xyy”, “yyx”} Input… Read More »

Java.lang.Number Class in Java

Most of the time, while working with numbers in java, we use primitive data types. But, Java also provides various numeric wrapper sub classes under the abstract class Number present in java.lang package. There are mainly six sub-classes under Number class.These sub-classes define some useful methods which are used frequently while dealing with numbers. These… Read More »

Mid-Point Line Generation Algorithm

Given coordinate of two points A(x1, y1) and B(x2, y2) such that x1 < x2 and y1 < y2. The task to find all the intermediate points required for drawing line AB on the computer screen of pixels. Note that every pixel has integer coordinates. We have discussed below algorithms for this task. DDA algorithm… Read More »

Count all perfect divisors of a number

Given a number n, count total perfect divisors of n. Perfect divisors are those divisors which are square of some integer. For example a perfect divisor of 8 is 4. Input : n = 16 Output : 3 Explanation : There are only 5 divisor of 16: 1, 2, 4, 8, 16. Only three of… Read More »

Output of Java programs | Set 9 (Garbage Collection)

Difficulty level : Intermediate In Java, object destruction is taken care by the Garbage Collector module and the objects which do not have any references to them are eligible for garbage collection. Below are some important output questions on Garbage collection. Predict the output of following Java Programs: Program 1 : Output: end of main… Read More »