Showing posts with label HackerEarth. Show all posts
Showing posts with label HackerEarth. Show all posts

The Magic HackerEarth Nirvana solutions Hiring Challenge

Navi got a task at school to collect N stones. Each day he can collect only one stone. As N can be a very large number so it could take many days to complete the task, but then he remembers that his mother gave him a magic that can double anything (i.e if he has 2 stones, the magic will make them to 4 stones). Navi can use this magic any number of time on the collected stone on a particular day and add this to the previously collected stones. Remember that he wants exactly N stones and he can't throw any stone. If he gets more than N stones then he gets 0 marks, of course he doesn't want 0 marks. Help him to collect exactly N stones in minimum number of days.

Input

First line of input will contain number of test cases (T). Then next T lines contains a single number N, which is number of stones Navi has to collect.

Output

For each test case, Print a single number which is the minimum number of days taken by Navi to complete the task.

Constraints

1 <= T <= 10^5
0 <= N <= 10^9

Find the smallest window in a string containing all characters of another string

Given two strings string1 and string2, find the smallest substring in string1 containing all characters of string2 efficiently.

For Example:

Input string1: “this is a test string”
Input string2: “tist”

Output string: “t stri”


Longest Increasing Subsequence

The longest Increasing Subsequence (LIS) problem is to find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order.

For example, length of LIS for { 3,2,6,4,5,1 } is 2 and LIS is {2,4,5}.


Practo Hiring Experience

Started from Written Test on HackeEarth

1) http://www.hackerearth.com/problem/algorithm/divide-to-three-33/
Code Solution Click : http://ideone.com/7M1o9j
2) http://www.hackerearth.com/problem/algorithm/good-times-vs-bad-times-3/
Code Solution Click : http://ideone.com/xj7o49

HackeEarth Flipkart's Drone

After listening to the news of testing of Delivery Drones by ....
But this was only possible if two of the shipping addresses had "V1-type" road connecting them(V1-type roads are the fastest in the city). So, Sachin and Binny ask you for a little help. They want you to tell them if they could send two orders together for two given locations or not.
Read Question at : http://www.hackerearth.com/problem/algorithm/sachins-drones/

Password Predictor

Danny has a possible list of passwords of Manny’s facebook account. All passwords length is odd. But Danny knows that Manny is a big fan of palindromes. So, his password and reverse of his password both should be in the list.
You have to print the length of Manny’s password and it’s middle character.
Note : The solution will be unique.