hulk
BAN USER
- 1of 1 vote
AnswersIdentifying if all the elements of a set (in enterity) is present in a list of sets.
- hulk in India
For example checking for set1 = {1,2} in {1,2,3}, {5,6} should return true as {1,2} is present in {1,2,3}. Similiary it will be true for {1,2,8,9}, {1,2,4}
But checking for {1,2} in {1,5,6}, {2,3,1} should return false as {1,5,6} does not contain all elements of {1,2} 2 is missing| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 1of 1 vote
AnswersGiven a set of possibly overlapping rectangles in different levels (All of which are "not rotated", can be uniformly represented as (left-bottom,right-top) tuplets), return a minimal set of (non-rotated) non-overlapping rectangles, that occupy the same area.
- hulk
The rectangle at lower level has more priority than at higher levels.| Report Duplicate | Flag | PURGE
Facebook Software Developer Algorithm Data Structures - 0of 0 votes
Answersi) Explain Polymorphism
ii) Output of the below code snippet :-
- hulk in Indiapublic class ParentTest { public int x = 0; public void print() { System.out.println("In Parent"); } } public class ChildTest extends ParentTest { public int x = 1; public void print() { System.out.println("In Child"); } public static void main( String args[] ) { ParentTest s = new ChildTest(); System.out.println(s.x); s.print(); } }
| Report Duplicate | Flag | PURGE
Morgan Stanley Software Engineer / Developer Java - 0of 2 votes
AnswersWrite a program to count the number of numbers between two numbers a, b that have the sum of their bits equal to a fibonacci number.
- hulk in India
For example between 15 and 17 there are two numbers that have sum of bits equal to a fibonacci number.
15: 1111 sum=4
16: 10000 sum=1 (fibonacci)
17:10001 sum=2 (fibonacci)
So the output will be 2 in this case.
Test case -
Input 15 & 17
Input 173 & 10000003210005
The interviewer asked this to code in 5 hours in any programming language & mail him the full working program.| Report Duplicate | Flag | PURGE
Vdopia Software Engineer / Developer Coding - 0of 0 votes
AnswersWrite a program to output the number of consecutive trailing zeros in the factorial of a number?
- hulk in India
For example:-
Input - 5!
Output - 1 (Since 5! = 120 & 120 has 1 trailing zero in the end)| Report Duplicate | Flag | PURGE
Jabong Software Engineer / Developer Algorithm - 0of 0 votes
AnswersImplement multiple producer and multiple consumer problem in java.
- hulk in India| Report Duplicate | Flag | PURGE
Infibeam SDE-2 Java - 1of 1 vote
AnswersCoding Round Assignment
- hulk in India
------------------------------------
MERCHANT'S GUIDE TO THE GALAXY
You decided to give up on earth after the latest financial collapse left 99.99% of the earth's population with 0.01% of the wealth. Luckily, with the scant sum of money that is left in your account, you are able to afford to rent a spaceship, leave earth, and fly all over the galaxy to sell common metals and dirt (which apparently is worth a lot).Buying and selling over the galaxy requires you to convert numbers and units, and you decided to write a program to help you.The numbers used for intergalactic transactions follows similar convention to the roman numerals and you have painstakingly collected the appropriate translation between them.Roman numerals are based on seven symbols:
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1,000
Numbers are formed by combining symbols together and adding the values. For example, MMVI is 1000 + 1000 + 5 + 1 = 2006. Generally, symbols are placed in order of value, starting with the largest values. When smaller values precede larger values, the smaller values are subtracted from the larger values, and the result is added to the total. For example MCMXLIV = 1000 + (1000 − 100) + (50 − 10) + (5 − 1) = 1944.
The symbols "I", "X", "C", and "M" can be repeated three times in succession, but no more. (They may appear four times if the third and fourth are separated by a smaller value, such as XXXIX.) "D", "L", and "V" can never be repeated.
"I" can be subtracted from "V" and "X" only. "X" can be subtracted from "L" and "C" only. "C" can be subtracted from "D" and "M" only. "V", "L", and "D" can never be subtracted.
Only one small-value symbol may be subtracted from any large-value symbol.
A number written in Arabic numerals can be broken into digits. For example, 1903 is composed of 1, 9, 0, and 3. To write the Roman numeral, each of the non-zero digits should be treated separately. In the above example, 1,000 = M, 900 = CM, and 3 = III. Therefore, 1903 = MCMIII.
-- Source: Wikipedia (http://en.wikipedia.org/wiki/Roman_numerals)Input to your program consists of lines of text detailing your notes on the conversion between intergalactic units and roman numerals. You are expected to handle invalid queries appropriately.
Test input:
-------------
glob is I
prok is V
pish is X
tegj is L
glob glob Silver is 34 Credits
glob prok Gold is 57800 Credits
pish pish Iron is 3910 Credits
how much is pish tegj glob glob ?
how many Credits is glob prok Silver ?
how many Credits is glob prok Gold ?
how many Credits is glob prok Iron ?
how much wood could a woodchuck chuck if a woodchuck could chuck wood ?
Test Output:
---------------
pish tegj glob glob is 42
glob prok Silver is 68 Credits
glob prok Gold is 57800 Credits
glob prok Iron is 782 Credits
I have no idea what you are talking about| Report Duplicate | Flag | PURGE
Infibeam SDE-2 Algorithm - 0of 0 votes
AnswersDesign a mobile app which based on the current location suggests Interesting places to the user. We already have a set of interesting places stored. The focus is on getting the nearby places say in radius of 100 Miles from current location quickly.
- hulk in India
The interviewer is mainly interested on how to store the interesting locations in a DB.| Report Duplicate | Flag | PURGE
Infibeam SDE-2 System Design - 0of 0 votes
AnswersMachine Coding 1 hour
- hulk in India
------------------------------
U have an organizational structure, which shows hierarchy of the organization. This hierarchy contains employees E or managers M who has some Employees or Managers reporting to M.
Employee has ( id, name, JobDesc, salary etc).
Design the data structure you would be using to store this hierarchy
problem 1: Given an ID of an employee , print all the employee ID's who are directly reporting or indirectly reporting to the manager.
problem 2: prefix search of employees by String. If employees have nishant and nikhil. If searched by "ni" we need to print all details of both nishant and nikhil.
problem 3(bonus): search should print all emloyee's and their details if a given string is subString of the name of an employee.(Like a phonebook contacts search)
P.S- This was asked to one of my friend in Flipkart.| Report Duplicate | Flag | PURGE
Flipkart SDE1 Data Structures - 0of 0 votes
AnswersGiven an array of positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array.
- hulk in India
You have to print the sub-sequence also.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm - 1of 1 vote
AnswersGenerate all Kaprekar Number (refer Wiki for Kaprekar number's definition) from 1 to 999999.
- hulk in India
I gave a brute force approach of generating all number in the range and checking if it is Kaprekar or not.| Report Duplicate | Flag | PURGE
Flipkart SDE-2 Algorithm Brain Teasers - 0of 0 votes
AnswersCoin Change Problem
- hulk in India
-----------------------------
Given an unlimited supply of coins of denominations C1, C2, ..., CN we wish to make change for a value V. Give an algorithm for producing change with minimum number of coins.
You have to print the denominations selected.| Report Duplicate | Flag | PURGE
Collective Software Engineer / Developer Dynamic Programming - 0of 0 votes
Answers1 2 3
- hulk in India
4 5 6
7 8 9
* 0 #
Given a starting number, find all 6-digit numbers possible, numbers can only be dialed horizontally or vertically.
Repetitions not allowed. Number can't start from zero and doesn't include * and #. For example, if last dialed number
is 3, the next one could be 1, 2, 6 or 9.| Report Duplicate | Flag | PURGE
Collective Software Engineer / Developer Algorithm - 1of 1 vote
AnswersDesign a web-site like Paypal.
- hulk in India
The interviewer was interested in the
i) Major components & the way they will interact.
ii) Various way of scaling the web-site to support many users
iii) Handling the failure cases like when the DB goes down, etc.| Report Duplicate | Flag | PURGE
Amazon SDE-2 System Design - 1of 1 vote
AnswersYou are given a matrix where some pixels are white and some are black. Basically there are different disjoint images in the matrix.
- hulk in India
a) Expand/Shrink the images
b) Count the no of images
c) Color the images
d) Rotate the images| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven a matrix pattern containing only 'plus' & 'dots',search no of times that pattern is present in a very large file which has a very large matrix which contains 'plus' and 'dots'.
- hulk in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 4of 4 votes
AnswersCar parking problem. An array given represents actual order of cars need to be parked. Like for example order is 4,6,5,1,7,3,2,empty. If cars are parked in some order like empty,1,2,3,7,6,4,2. Some person needs to get them into correct order, list out all instructions to the person to get in correct order with least number of swaps.
- hulk in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersMachine coding round : (Time 1hr)
- hulk in India
expression is given and a string testCase, need to evaluate the testCase is valid or not for Expression
Expression may contain letters [a-z]
Expression may contain "."( '.' represents any char in [a-z])
Expression may contain '*'( '*' has same property as in normal RegExp)
Expression may contain '^' ( '^' represents start of the String)
Expression may contain '$' ('$' represents end of String )
Sample cases (Exp, testCase, Result) below
1. ab, ab , true
2. a*b , aaaaaab , true
3. a*b*c*, abc , true
4. a*b*c , aaabccc, false
5. ^abc*b, abccccb , true
6 ^abc*b, abbccccb , false
7 ^abcd$, abcd , true
8 ^abc*abc$ , abcabc, true
9 ^abc.abc$, abczabc , true
9 ^ab..*abc$, abyxxxxabc, true| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Algorithm - 0of 0 votes
AnswersCoding in Computer : (Time 1hr)
- hulk in India
Expression is given and a string testCase, need to evaluate the testCase is valid or not for Expression
Expression may contain letters [a-z]
Expression may contain "."( '.' represents any char in [a-z])
Expression may contain '*'( '*' has same property as in normal RegExp)
Expression may contain '^' ( '^' represents start of the String)
Expression may contain '$' ('$' represents end of String )
Sample cases (Exp, testCase, Result) below
1. ab, ab , true
2. a*b , aaaaaab , true
3. a*b*c*, abc , true
4. a*b*c , aabccc, false
5. ^abc*b, abccccb , true
6 ^abc*b, abbccccb , false
7 ^abcd$, abcd , true
8 ^abc*abc$ , abcabc, true
9 ^abc.abc$, abczabc , true
9 ^ab..*abc$, abyxxxxabc, true| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou have given a file containing sentences. Now you are given a sequence of characters. You have to find the starting location of each word containing one of the permutation of the word.
- hulk in India
e.g File - 'She submitted her assignment.' Input Sequence - imt. Since the file contains the word 'submitted' containing the sequence 'mit' which is a permutation of 'imt' So it will return 1. Similiarly it will return for all other words.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Data Structures - 0of 0 votes
AnswersGiven a matrix you have to find the shortest path from one point to another within the matrix. The cost of path is all the matrix entries on the way. You can move in any direction (up, down, left, right, diagonally)
- hulk in India
e.g.
5 9 10 1
3 7 4 4
8 2 1 9
So shortes path from (0,0) to (2,2) is (0,0)--(1,1)---(2,2). Path cost - 5+7+1 = 13| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm
I know the rules very well. If this was a non-interview question I would have posted this in Forums not here.
Now coming to this question, if you have given interview in any decent product company for mid-level java role then you will know that this is quite common multi-threading question.
In fact I was asked this same question in two companies :)
The interviewer told not to use any BlockingQueue implementation there in Java inbuilt.
The discussion moved on from a standard producer / consumer implementation in which we have to use our own BlockingQueue implementation.
For standard producer-consumer implementation you can refer:-
hxxp://javarevisited.blogspot.sg/2012/02/producer-consumer-design-pattern-with.html
Definition of Producer- Consumer problem from wikipedia:-
" The producer and the consumer, who share a common, fixed-size buffer used as a queue. The producer's job is to generate a piece of data, put it into the buffer and start again. At the same time, the consumer is consuming the data (i.e., removing it from the buffer) one piece at a time. The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer."
In this case instead of a single producer producing data and single consumer consuming there can be multiple producers producing data and multiple consumers consuming them.
I think what he meant is let's say we have two paths from 1 to 4:-
i) 1---u---2---d----3---u---4
ii) 1--u---6---u----7---u---9---10---u---4
1---u---2 means the path from 1 to 2 is uphill.
Then as per the problem shortest path we have to return is (ii). (i) is not a valid path as we are changing the path direction more than once ( once from uphill to downhill,then downhill to uphill & then again downhill to uphill.)
i) Inheriting a singleton class should be prohibited. Making a singleton class inheritable means any number of child classes can inherit from it creating multiple instances of the singleton class which will obviously violate the principle of singletons.
ii) We will be able to create a copy of the Object by cloning it using the Object’s clone method.. To avoid this, you need to override the Object’s clone method, which throws a CloneNotSupportedException exception:
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
iii) If Singleton Class implements the Serializable interface, then instances can be serialized and deserialized. However, if you serialize a singleton object and subsequently deserialize that object more than once, you will have multiple singleton instances. To avoid the above you need to implement readResolve() method.
private Object readResolve() {
return INSTANCE;
}
Repjacobghester2, Accountant at ASAPInfosystemsPvtLtd
I'm an artist at heart. I went from print design to web development and lots of server administration professionally ...
Repannadwilliams31, Applications Developer at National Instruments
I am Anthony, Human Resources specialist with a decade of successful experience in hiring and employee management.I am a ...
Replcarton941, Android test engineer at 8x8
My name is Lilly. I grew up in Somerset and currently live in the US. One desire that has always ...
RepIn 2008 I was licensing race cars in Los Angeles, CA. What gets me going now is promoting husband vashikaran ...
Repdeloresrdaniels, Cloud Support Associate at JDA
Crossed the country marketing wool in Nigeria. Was quite successful How to Get Girlfriend Back By Vashikaran Mantra . Spent a ...
Repmariacbrister, Graphics Programmer at Graphic Systems
Hey, I am Maria and I am from Bluefield. Currently, I work as a freelancer graphic artist. From an early ...
RepTinaaJohn, Cloud Support Associate at AMD
Hi,Everyone.I am an art teacher at Woodson Institute.Foster and encourage critical thinking and analysis about art and ...
RepMaryHDavis, Employee at ASU
Had a brief career promoting wooden tops in Salisbury, MD. My current pet project is lecturing about human hair in ...
RepMiraDavis, Computer Scientist at Accenture
I am School librarian and also teach students the fundamentals of using a library and its resources .I write and ...
Replillymartin, Senior Software Development Engineer at Aristocrat Gaming
Hi everybody! I'm Lilly, a 22 year old girl from Us. Master of economic and financial evaluation of development ...
RepPandit Ji is the best vashikaran expert for vashikaran mantra for girlfriend in Mumbai.It is the strongest method to ...
RepTop Tiers provides latest english premier league articles and news to keep you up to date. Visit our website today ...
Repcharlesndouglass, Employee at VANS
I am Michael from Nantucket USA. I am working as a Power plant dispatcher in Matrix Design company. I am ...
Reptaniajclover, Analyst at Amdocs
Hi, I am Tania from Tuckahoe USA, I am working as a Public relations representative in Gamble-Skogmo company. I like ...
RepOur mission is to provide informative and Self Improvement advice to help people live their lives better set definite goals ...
RepWilliamDGiles, Cloud Support Associate at ADP
Spent 2001-2006 creating marketing channels for tar worldwide. Was quite successful at building tobacco for farmers. Won several awards for ...
Repabbyherza, Animator at ASAPInfosystemsPvtLtd
I am Viola .I am A public relations consultant, a communications specialist who works as an intermediary between the public ...
Reparlenekraft8, How to book a seat on Southwest airlines flight at Absolute Softech Ltd
I am a coding specialist from MD,USA.I’m indifferent to most items on the planet.Participated in creating ...
RepKimRPierce, Employee at Achieve Internet
I am a customer service-oriented Travel Agent in Travel and Tourism industries. I strongly believe that the skills and abilities ...
Repaaronmdunlap6, Area Sales Manager at Achieve Internet
Hi, I am an HR Analyst with extensive experience delivering innovative solutions at the corporate level. Expertise in employee relations ...
Repmarybritt, Android Engineer at Centro
I am Mary from Wilmington. I am working as a Graphic Designer in Super Enterprises. I also write articles and ...
Repstacyrdavid, Associate at Abs india pvt. ltd.
Hi, I am Stacy working as a Cashier in Dollar store the US. I work for Us government to Collect ...
Repbrandysolsen, Area Sales Manager at AMD
I am a Social butterflies who enjoy travel.Have fun doing this job and project an atmosphere that reflects Amazon ...
Rephamishleeh, Blockchain Developer at ASAPInfosystemsPvtLtd
Property custodian with a reputed organization and help in keeping accurate check over the supplies and inventory of materials and ...
Repbarrybzane, AT&T Customer service email at ASU
By Profession, I am a Child protective services social worker in Newark USA. My strong interest is in yoga. My ...
Repshirleygause93, Analyst at Absolute Softech Ltd
Hi, I am Shirley from taxes, Conducted a re-profiling project which enabled our customers to receive orders more efficiently.Planning ...
Repashleymbosse, Associate at Accenture
I am an enthusiastic, hard-working and disciplined Catering Assistant with excellent track-record in working in the food industry. I am ...
Repethelynfrose, Computer Scientist at 247quickbookshelp
Hello, I am Ethelyn and I live in Lake Worth, USA. I am working as a Dog Trainer and Dog ...
RepHuge collection of cheap ammo for Rifle, Handgun, Shotgun & Rimfire from top brands you are looking for.
Repmonicaralvarado94, Korean Air Change Flight at Athena Health
I am fond of reading stories then reading articles which are all about a story of a beautiful nature and ...
RepGet powerful wazifa to know who did black magic. Guru Ji is the master of black magic totke, kala jadu ...
Can you explain this a little more with an example?
- hulk February 10, 2017