sasi.baratams
BAN USER- 0of 0 votes
AnswersGiven two version numbers as string (can be very long) write a function which returns 1 if first one is latest, -1 if second one is latest and 0 if they are equal.
- sasi.baratams in India
Ex: 1.2.0.4.5
1.2.1
We have write our split method with period as delimeter and we have to handle all the malformed version numbers like 1..2.0 etc and similar other exceptions| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 0of 0 votes
Answersa) You have a package repository in which there are dependencies between packages for building like package A has to be built before package B. If you are given dependencies between the packages and package name x, we have find the build order for x.
- sasi.baratams in India
Ex: A → {B,C}
B → {E}
C → {D,E,F}
D → {}
F → {}
G → {C}
For package A, build order is E B F D C A (may not unique)
Given a function Set<Package> getDependencies (Package packageName) which returns a set of dependencies for a given package name, write a method List<Package> getBuildOrder(Package packageName) which returns the build order
b) How would you handle cyclic dependencies (Algo only)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array of stock prices from day 0 to N-1 of a company X, we have to find the max loss that is possible. Loss occurs if stock is bought at higher price and sold at lower price.
- sasi.baratams in India
Ex: 1 2 3 7 5 8 9 4 6 10 12 (algo and code including main)
Max Loss is 9 - 4 = 5 (Possible losses are 8-4 = 4, 7-5 = 2 etc). Max difference between stock price is 12 - 1 = 11 but max loss is 9 -4 = 5| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind the angle between hours hand and minutes hand.
- sasi.baratams in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Brain Teasers - 0of 0 votes
AnswersGiven a string, we have to find all the unique words present in the string. Assume that words are delimited by space character and we have to write our own split function. We have to handle all the edge cases
- sasi.baratams in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 0of 0 votes
AnswersYou are given an infinitely long array of integers in which some part of the array is sorted and all other entries contain terminating character ($). Given a number how will you search in the given array. What is the complexity of the search operation if the number is not present in the array
- sasi.baratams in India
Ex: 1 2 3 4 5 6 7 8 9 $ $ $ $ $ $ $ $ $ $ $ ….........................| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersTwo numbers are given in the form of linked list with most significant number as the head, we have to add them and return the resulting number as a linked list again.
- sasi.baratams in India
Ex: Input: 1-->2-->3 4-->5 Output: 1-->6-->8| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm