# InterviewInTech

## Hamiltonian Graph – Paper Boy Problem

Shyam needs to distribute newspaper to all the houses while following these rules: He can start from any vertex. When he is on a vertex, he must distribute the newspaper. You can only travel to a vertex that is connected to the current vertex by an edge. You cannot visit a vertex which is already…

## Maximum Difference in an Array

You are given an array of integers and must compute the maximum difference between any item and any lower indexed smaller item for the possible pairs, i.e., for a given array a find the maximum value of a[j] – a[i] for all i, j where 0 <= i < j < n and a[i] <…

## Counting Valleys – HackerRank

Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly steps. For every step he took, he noted if it was an uphill, , or a downhill, step. Gary’s hikes start and end at sea level and each step up…

## Alice and his candy

Alice is a kindergarten teacher. She wants to give some candies to children in her class. All the children sit in a line and each of them has a rating score according to his or her performance in the class. Alice wants to give at least 1 candy to each child. If two children sit next to…

## Trailing Zeroes in Factorial of a Number – FCTRL – SPOJ

Now we can approach it in 2 ways – the first approach is to calculate factorial of a number and then calculate the number of trailing zeros from the result. But for any value greater than 12 we will see integer exceed. So let’s go with the second approach and Find a relation between number and…

## SPOJ – FCTRL – Factorial

The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little-simplified view). Of course, BTSes need some attention and technicians need…

## Reverse ArrayList Between 2 Given Indexes

Given an ArrayList and we need to reverse list from given startIndex to endIndex. example – List – [1,2,3,4], startIndex = 1, endIndex = 3 result = [1,4,3,2] List – [1,2,3,4,5], startIndex = 1, endIndex = 4 result = [1,5,4,3,2] Approach 1 – This approach starts swapping elements from startIndex and endIndex until startIndex is greater…

## HashMap in JAVA

Consider a scenario where we need to store data in the form of key value pairs. Which data structure will we use? Well, The obvious answer which comes in our mind is Map. HashMap is Hash table based implementation of the Map interface which stores data in the form of key value pairs. This class provides…