hprem991
BAN USER
- 0of 2 votes
AnswersI am surprised by this GS question.I thought this is one of the classic number theory partition problem which is so hard that the best algorithm is approximation one.
- hprem991 in United States
Given value, find all possible combination of ways which equals to that sum.| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer Coding - 1of 1 vote
AnswersGoogle Fucked up question.
- hprem991 in United States
Given a random list of appointments (Start Date , End Date). Find all the appointments that are colliding.
This pretty easy looking question screwed me up today.There are tons of edge cases, I couldn't complete em all and 45 minutes pass like 15 minutes while explaining and coding same time.| Report Duplicate | Flag | PURGE
Google Software Engineer Coding - 0of 0 votes
AnswersGot Sp00ked by MS simple question..
- hprem991 in United States
Eight Ball problem, find Minimum steps to determine the heaviest one.
Anyone know the answer is 2 in case of 8 balls.. Question is code getHeavy when number of balls are not determined.
int getHeavy(List<Integer> balls){
// Your solution
}| Report Duplicate | Flag | PURGE
Microsoft SDET - 1of 1 vote
AnswersWAP to Convert Hex String to Equivalent decimal Integer.
- hprem991 in United States| Report Duplicate | Flag | PURGE
SDE-2 - 0of 0 votes
AnswersDesign Distributed Web Crawler.
- hprem991 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersImplement bool isPalindrome(SingleLinkList *node) in constant Space.
- hprem991 in United States for Chennei
Sorry for incomplete post earlier..| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C++ - 0of 0 votes
AnswersImplement bool regex() Function.
- hprem991 in India for Chennei| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C++ Coding - 1of 1 vote
AnswersImplement bool isBST(Tree * root)
- hprem991 in India for Chennei| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C++ Coding - -3of 3 votes
AnswersDesign and code static simulator for all gates .i.e. AND / OR / XOR etc.
- hprem991 in United States
Where the simulator has to work properly not only for the binary digit but also for the algebraic inputs (i.e doubles as a input type.)| Report Duplicate | Flag | PURGE
Senior Software Development Engineer Algorithm C++ - 0of 0 votes
AnswersHow do we design a class.forName("CLASS") , kind of function?
- hprem991 in United States
Where the function will accept a string (as a Class Name) as a parameter and accordingly convert it into the subsequent CLASS object.| Report Duplicate | Flag | PURGE
Solutions Architect Algorithm C++ - -1of 1 vote
AnswersIs there any difference between the usage of void pointer and unsigned int ? if yes what the advantage of one over other?
- hprem991 in United States
Guys I havn't thought guys commenting here are idiots as well. so please read the detail explanation for it in my below comment. :)| Report Duplicate | Flag | PURGE
Software Architect C - 0of 0 votes
AnswersDesign LRU in C++
- hprem991 in India| Report Duplicate | Flag | PURGE
StartUp Software Architect Algorithm C++ - 0of 0 votes
AnswerDesign Garbage Collector in C++.
- hprem991 in India| Report Duplicate | Flag | PURGE
StartUp Software Architect Algorithm C++ - 0of 0 votes
AnswersDesign a Tic Tac Toe Game. Classes Segregation and Code Flow.
- hprem991 in India| Report Duplicate | Flag | PURGE
StartUp Amazon Software Architect Software Engineer / Developer Algorithm Android Application / UI Design Arrays Assembly Automata Behavioral Bit Manipulation Brain Teasers C C++ Object Oriented Design - 0of 0 votes
AnswersGiven a Big XML File. You have to design and implement the Data Structure which stored their keys and its value accordingly in C/C++ language.
- hprem991 in India for Protocol Devlopment
Write a Program to Store all the given XML content to your designed Data Structure and Retrive it . Basically SAX/DOM parser :)
Contraints :-
1> Data Structure should not be a flat file type.
2> Every Program code must be modular and each module should not exceed 15 lines of code.
3> No Usage of STL library functions.
4> Each Module should not have return type other than success and failure of operation.
5> Use Memory management at the most.
6> Design and problem approach crutial.
7> Minimal Space and Time Complexity for each code.
8> No Static variable usage and all memory allocation should be dynamic.
9> There are occasion like a parent has more than one child you have to take care of such cases.
10> Handle all possible error condition.| Report Duplicate | Flag | PURGE
Samsung Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersWrite a MergeSort for Two Different Sorted Link List.. Emphasis on TO and SO with all Error Conditions...
- hprem991 in India for SEL| Report Duplicate | Flag | PURGE
Samsung Software Engineer / Developer C - 0of 0 votes
AnswerHow do you Design Access Specifier in C.
- hprem991 in India| Report Duplicate | Flag | PURGE
Samsung Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersGiven pointer
- hprem991 in India
char *p = <body> <tagname1>Tagvalue1</tagname1>
<tagname2>Tagvalue2</tagname2>
<tagname3>Tagvalue3</tagname3>
..
..
..
<tagnamen>Tagvaluen</tagnamen>
</body>
Write a Program to replace a Tagvalue from existing Value to User Provided New Value..
example : - Your Function Func(TagName,New tagvalue) should replace the existing tagvalue of the Tagname to NewTagName..
Given Constraints :-
1> Function should be granular enough.
2> Its actually a design question so approach is important.
3> Take Care of Error Condition . Like TagName not found etc.
4> Also make sure the conditions like if the Given Tagvalue is not of Same Length that proper handling etc.| Report Duplicate | Flag | PURGE
Samsung Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersDesign the XML Parser.
- hprem991 in India| Report Duplicate | Flag | PURGE
Samsung Software Engineer / Developer Application / UI Design
0 Answers Is Amazon Joking Around?
Amazon is known for its tough tech screening rounds but even if you nail those technical question with best possible solution, are you getting screwed??
- hprem991 August 04, 2017
Before this experience, I would have said NO but now it is looking different..
I was being picked up by their recruiter and asked to present myself for phone screening as they liked my experience (thats what they said ).
Now, I wouldnt mind.. being the fact that I am doing great in what I am doing.. its just a 1 hour call.
Well, call lasted for like 55 mins.. Was asked 2 algorithmic questions with code and follow ups and some pretty team / experience related question..
I nailed the tech rounds so much that the interviewer said, I got questions done with most optimal solutions and of course before time.
So, if they liked my experiences ( thats what they said they called me at first place).. Did they rejected me for same experience or Amazon interview has become a joking ground now?
Any thoughts??| Flag | PURGE 1 Answer Subscription Mail Cancellation .
Hi ,
- hprem991 May 06, 2013
I am not sure if this is with me or with everyone else as I am getting a lot of mails into my private and registered mail id regarding the question / discussion after every user comments from here.
I may have put comment of my own on the same question sometimes back and may becoz of that I am getting the same but the question here is the is no way to unsubscribe those subscriptions.
Although , C C does have the checkbox at the bottom of the question under discussion but I am not sure why it is "Checked" by default and always gets redirected to mail account.
Gayle, Could you please provide the single point of subscription / UnSubscription button which will help user to regulate this mail forwarding option.
Thanks
Prem| Flag | PURGE 2 Answers Technical Issue With C C Server
There is an issue ( I reported as Bug Already) .When User were trying to put Comment or Reply on any question causes Server Error ("The server encountered an error and could not complete your request.") message flashes on Screen but the note is already being processed by the server (Sometimes).
- hprem991 April 24, 2013
This is causing some user to re-submit their words making number of duplicate comments or in some cases missing their comments.| Flag | PURGE
My Algo may be the kinda bit Complicated but I guess the implementation will have its advantage.
1> I will use Trie to Store the words (Not Letters). Coz search string will have words like "the ", "what" etc more frequent.
2> Now For every query .i.e. in trie end node , I will put the frequency count.
Now I even can have the Time complexity to be as minimal as possible coz we are searching word graph (DWAG) and the space of Trie being the minimal, the optimisation will be the best one...
Anymore or better algo is highly appreciated.
-1 for your Algo.. Coz.. You are assuming the search String is ONE WORD Sentence which is not the case..
The question is query String.. not query word..
Also, the algo sound fishy.. I mean for words like "Britney Spears".. What if the "Britney" and "Spears" individually way less than top 100 but combined String is on the top. coz the way you are framing definitely will have the common words like "the" frequency way above.
See buddy I am having 4+ expr in C/C++ and now I am using C# for cloud project. Code and logic remains the same but C/C++ is much more complex than C# and .net. I mean the transition for me was easy coz the reverse transition will take it own toll..
So be Sure.. thats not a piece of cake as .Net (My View)
I think probably the hash is one option here.
1> I will hash the elements of one array into the hash table.
2> For Every element in the second array try to find the collision and for each collision print value.
Time Complexity = O(m)
Space Complexity = Hash Table Creation.
Clearing Ambiguity and responding to this question here.
Certainly we need to assume that the tree Has to be Binary Tree to be possible. So the algo goes here.
We need to create a Binary Tree on the basis of edge weight value as node and do the following operation.
1> For Unorder Binary Tree, we need to traverse the full tree to get the following values
a> Smallest Edge Node Value and Second Smallest Edge Node Value. As node is now edge.
b> Total Weight of the Tree
So the Max value will be Total minus the two smallest Node value and there will be three sub tree.
Time Complexity will be O(n) and Space O(1).
2> For Ordered Binary Tree like BST the algo remain the same only the Time Complexity goes to O(log n) as searching for the two smallest edge will be easier.
@Martin.. Well I believe... thats was a Amazon First Round.. I too humped my First round last year becoz of similar reason.. I wasn't actually prepared for the kind of question they will ask in First round and went with big algo's and all.. but finally the time went like anything..
From my experience what I can tell U.. is leave the rest on them. Even if you try to contact them they won't be able to help you. Coz its online and who know who is going to check it.
And probably U gonna get a next chance after 6 months time as well.. But hope U'll get better than me.. coz now I got call for ASE after I screwed last year call for SDE 2..
Well... I guess this is the Caller dependency...
For Normal Cases we can Say if Thread A only executes then the min value will be there.
and For both thread executes the max value will get generated, But Still there are more complexity involved if we keep discussing.
But i n Laymen Term.
Min=3 ,
Max =8
@Eugene... Who Said C++ Does not Support nested Class ? Search google.. Anyways.. For your information about language.. if your are experienced programmer .. tell me one question.. if you have the language limitation or language operatibility limitation.. will you use or promote language ?? But than how come Java /C++ stand out ?? So what you are claiming here now DOES NOT MAKE SENSE..
There is not benefit of doubt .. in fact for programmer like me there should not be and if there it is U need to clear it out.
So For your info.. here it is.. the only diff with Java from C++ is Memory management.. How java Does MM is BYREFERENCE (no pointer in laymen term).. so even there is one java type version of C++ .. most people called it as C#.. it does the exact same kinda MM what Java Does..
So from my previous expr with Microsoft where I was working on Windows Phone 7 Logger .. I can tell you that the MM layout does follow up almost everything what C++ MM does.. however there is some advance concepts being taken care.. but for question like this no doubt it does.
And I do apologize for my explanation coz I am not a management guy to explain bit and pieces in tech forum and I expect that people reading / commenting have atleast the gap filling knowledge to understand what I meant. :)
@eugene.. Thanks for your insight .. but I would rather like to tell you that in C++ the memory Layout happens EXACTLY what I said.. I am Device Driver Programmer.. and most of the time.. I use this memory management layout to coordinate different process accessing the same memory location..
Well if U know what I meant to say that U understood it.. :D
Well I do Seriously Doubt on what @alex has told up.. People having Java Env Can check with changing the variable name as mentioned by him.
However, being more of the C++ coder, I have a firm idea about what is happening but need to get it verified as Java Don't support pointer.
IMHO, when stack object of Y is being created in the memory stack, the member variable Z will have its address to the offset of 0 bytes from the object of Y.. But as object Y is constructing another object W on the top of its stack, it MAY have this object being created to the offset of 0 bytes to the memory address of the static class Y.
As a Consequence , When we put X.Y.Z.. Compiler goes to the base address of Y and then tries to find the variable Z which after the W's object created lies in the offset of 0 bytes to the base object.
Now the beauti lies in assigning the variable Z which itself is static here.. So as the object W is being created after the Z assignment inside Y, it will get overridden to new value of Z as mentioned in class W.
Well, I guess the way I would like to Achieve this is by something like this.
1> Grow First Stack from the array[0].
2> Grow Second Stack from array[n-1].
3> Here Comes the Challenge. For which I may go for something like this.
Initially I assume array[n/2] and the third array and start growing it accordingly. but when I hit the stacktop of third Stack to the stacktop of any of the other stack, I would recalculate the stackbase of the third array and shift all of its allocated value accordinly.
To recalculate the stackbase of third array probably I may use, the stacktop of the array which does not collide to the stackbase of the third array to find the spacing still available in an array and then divide by 2 to make sure I have spaces left for all the three stack to grow again.
Similarly I would think of stackbase of third array to the stacktop of either array and make again adjustments accordingly.
Ofcourse the collision case would create the time complexity JUMP hugely.. coz I need all stack operation working on together again right from the beginning.
Java !!! Well M not a very much of JAVA Coder unlike C++ but My Answer would be like.
Abstract Class in More flexible than interface . means, i will put some logic which later on I can change easily in the derived classes.. Well that says the saying " In interface by Default all methods are abstract". So only Definition in Interface.
However coming to this question. here both the implementation are more or less same. Except the fact that if I want a method Say get1() to have some bydefault logic, I can't do in interface, i need to have Abstact Class.
but along side I am okei with your rest of the responses !!!
M Not Sure.. Why U think there is the limitation.
For Instance, if U find it difficult to implement generics in C. U should use void pointers.. all that template or generics can do is use an Abstract layer to make things easy.. but Finally U can do in C the same thing wat C++ or java Can Do..
I can write a Code of Stack / Queue or rather even a Vector in C using void pointer..
This is obvious question.
1> We need to use template class.
2> API's are very general API's like push /pop/top /size.
3> I would rather like to use Vector as it has the flexibility of resizing.
4> Yes, template class generates place holder's according to datatype and so it won't be an issue.
Implementation Fairly Easy
<template typename T>
class MyStack {
private :
vector <T> stack;
int size;
T *top;
public ;
bool Push ( T data)
{ }
T Pop()
{}
T Top()
{}
int Size()
{}
};
Now these API's are fairly easy to implement.
First of all the question need modifications.
Two trees means two each of n node.. So the Algo is pretty easy for O (n).
Steps :-
1> Visit all node of tree One and push them in queue Q. i.e. O(n) // n is the no. of node in tree 1.
2> For each value in queue Q.
dequeue the value from the queue Q.
Now put this value into the Tree 2 using the BST rule.
end of For // O(m).. // m is the no of node in tree 2
So total time complexity is O(T)=O(n)+O(m) .
if m==n the O(n)
else if m<n
O(n)
else
O(m)
If Time Complexity Matters the Most than , you can use the KMP Algo modification for integer accordingly.Its 0(n) , else if 0(n2) is okei than just need to use to loops one for picking each integer in a series and other for checking just the immediate next if its value is greater than itself and collection accordingly.
- hprem991 November 23, 2011WOW, Great insight Laxmi.. Thanks for sharing..
Yeah that's absolutely correct what she has told above lines. However adding further towards answering this question from HP , It yes a memory leak, what has actually happend here is during allocation a chunk of 10 bytes memory from heap is returned and the head is being holded by pointer p. but when I say p++ I said p to just forward its next data address (i.e. add of P + 1*datatype of p), so Now P here is just unaware of its first byte of allocation and now when I say free(p),and all but first address gets deleted. Reason free() usage of knows frm where to start releasing to till when, which in this case being array goes releasing till char 10 but avoiding first one.
Good Question..
Lemme give my view.. Every prgm either hv to compromise of Time or Space Complexity..
Algo:-
1> Space Compromise :-
a> Read a array and hash it.
b> Before putting into hash table check if that place is filled.
c> if Filled its duplicate else not keep it in there.
2> Time Compromise :-
Usual Sorting algo with little modification will work.
a> Pick an element search for its duplicity in the array with min complexity.
Good Question..
But as far as I know, return value is only the compiler check. It has nothing to do with the call stack...
Infact call stack has space reserved for :-
1> All function parameters.
2> All Variables within that scope
3> Any Variables which are used to call for another subroutine.
I feel its a tricky question,and even if you do something stupid as this.. Your code will not compile " Function should return a Value " or " Parameter Mismatched " in case of C / C++ . So call stack itself will not generate if the code is not able to compile.
Oh Come On Guys ... Its they who are judging you.. Let them know what you know.. and what is correct... if I get the very basic or stupid question in any interview.. regardless of my expertise.. I would give my answer and if possible with added flavour of my experience regarding why is that so........
So, its always suggested to answer the concepts of inheritance, polymorphism and Encapsulation in Java and how is being achieved to make Java an Object Oriented for this question.
Good Question . I guess it depends on designer how do you design your class. For me..
Base class watch should have private methods like ..
int seconds () // returns seconds from 0-59
int Minutes ()
int Hours ()
// can extends to calender feature
public methods like set and get function
You can now extend this base class to derived class called
class Wrist watch extends Watch
Now putting wrist watch features accordingly..
RepGayle L McDowell, CEO at CareerCup
Gayle Laakmann McDowell is the founder / CEO of CareerCup, which provides programming interview prep for candidates interviewing with Microsoft, Google ...
Rep
Rep
RepI am Jenae Wilder and I work as a content writer, A writer at day, and a reader at night ...
RepDiscover the best online vaporizer store to buy quality vaping accessories at affordable price. Visit NY Vape Shop, specialized in ...
RepLooking for the best day care center Charlotte? Pal-A-Roo’s Child Development Center is a family owned child care facility ...
Repour goal is to help individuals companies and organizations of all kinds to communicate with their clients customer and employees ...
RepAmber Van is the top rated company that offers friendly and professional removals services.Our featured services includes domestic moves ...
RepStevenBLuis, Data Scientist at Achieve Internet
Choose the best quality vaping accessories at Ny Vape Shop. With different types of quality vaporizers, we are one of ...
RepHazelMiller, Site Reliability Engineer at Delve Networks
Hazel Miller has been a stalwart advocate for sound public policy that advances the jobs creating potential of America’s ...
RepLarry Alvarez, Analyst at ASU
Prestige Luxury Rentals is one of the most renowned car rental companies in USA. We are locally owned and operated ...
RepSCREENish employee time tracking software can be used as desktop or mobile app. Once the employee has tracked his working ...
RepHad a brief career donating velcro in Africa. Spent several years training sock monkeys in Pensacola, FL. Gifted in working ...
Repcrystaljben, Technical Architect at Expedia
Hello, I am Crystal. I am a master’s prepared Registered Nurse with over 2 years clinical experience in addiction ...
@Shashi... Well I didn't got why U are doing the last if check
- hprem991 January 23, 2013if(S[i]=='?'){
S[i]='A';
}
This makes logic highly vulnerable..
Example..:-
You are always replacing last character with alphabet 'A' if its '?' why ??