sunny.010203045
BAN USER- -1of 1 vote
AnswersHow to find the smallest number with just 0 and 7 which is divided by a given number?
- sunny.010203045 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersLucky numbers are those numbers which contain only "4" and/or "5". For example 4, 5, 44, 54,55,444 are lucky numbers while 457, 987 ,154 are not.
- sunny.010203045 in India
Lucky number sequence is one in which all lucky numbers exist in increasing order for example 4,5,44,45,54,55,444,445,454,455...
Now we concatenate all the lucky numbers (in ascending order) to make a lucky string "4544455455444445454455..."
Given n, your task is to find the nth digit of the lucky string. If the digit is 4 then you have to print "Hacker" else you have to print "Earth".
Input:
first line contain number of test cases T , next T line contain a single interger n.
Output:
For each test case print "Hacker"(without quotes) if nth digit of lucky string is "4" else print "Earth"(without quotes) if nth digit of lucky string is "5".
Constraints:
1<=t<=10^5
1<=n<=10^15| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersProblem Statement
- sunny.010203045 in India
There are three types of tickets and stations available in CodeCountry A, B and C. Tickets of type A can only be bought at stations of type A and end at a station of type B. Tickets of type B can only be bought at stations of type B and end at a station of type C. Similarly, tickets of type C can only be bought at stations of type C and end at a station of type A. Also, you can only travel from station i to station j if j > i, i.e. you can only move forward and if the ticket type bought at station i ends at station j.
The cost of a ticket is j x j if you travel a distance of j. For example if you start at Station 3 and end at station 5 the cost is 2 x 2=4.
Now, you want to travel from Station 1 to Station N using trains in CodeCountry. You are given the type of each station. Output the minimum cost of the journey.
Note that station N will also have a type and you must reach it using a ticket of compatible type. Output -1 if it is not possible to reach from station 1 to station N
Input Format
The first line contains the number of test cases T. This is followed by T lines one for each test case.
Each test case consists of a string representing the types of each station. The i-th character of the string represents the i-th station's type.
Output Format
Output the minimum cost of the journey, one line per test case.
Constraints
The number of test cases is atmost 50.
There will be atleast 2 stations and atmost 15 stations.
The first station (station 1) is always of type A.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 2 votes
AnswersYou are given an array A with elements 0 to n-1, numbers can be repeated in the array. Create n sets where
- sunny.010203045 in United States
S[i]={a[i],a[a[i]],a[a[a[i]]]…}. Set has all elements unique. Find the size of the largest set.
Input:
First line contains n, size of the array. n<1000
Next lines contains n numbers, each element of the array
Output
Prints one number: Size of the largest set.
Sample Test Case:
Input: {3,1,2,0}
Output: 2
Explanation:
Four possible sets are
{3,0},{1},{2}{0,3}| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersGiven an array of integers. Remove minimum number of elements from the array such that the largest and the smallest number does not differ by more than two times.In other words if x is the minimum of the remaining elements in the array and y is the maximum than y<=2x.
- sunny.010203045 in United States
Find the minimum number of numbers that has to be removed from the array so that the largest and the smallest number differed in no more than two times.
Input:
First line contains n(2<=n<=10^5), the size of the array
Second line contains n integers, the elements of the array.
Output:
Single integer - the minimum number of elements to be removed from the array.
Sample Test Case:
Input: {4,5,3,8,3,7}
Output: 2
Note: In the above sample you can remove the fourth and the sixth measurement results (values 8 and 7). Then the maximum of the remaining values will be 5, and the minimum one will be 3. Or else, you can remove the third and fifth results (both equal 3). After that the largest remaining result will be 8, and the smallest one will be 4.
You do not need to write full code. Just fill out the given function.| Report Duplicate | Flag | PURGE
Amazon SDE1