text: hprem991BAN USER
  View Count could be a major factor. Question is what is the condition or factor to cause a post / product a trend? is it people view, click, people response? Based of that you can use priority queue at least for normal interview based question but in real time, this could blow up heavily
  I love the question and the response from the above scammer.. Kudos.. Bitches.. this aint support website to ask or respond such question
  @Daniel, I had O(nlog) solution and I was almost there.. Everytime I got something, he was pointing out another edge cases to the point that he himself was confused at times..
  I haven't read you full solution but I can tell you one thing that during conversation, when I was stuck at one use case, he asked me burte force solution, which I gave instantaneous and it is O(n2) which he agreed to solve the problem but we both were trying to improvise.
  So your above solution may not be challenging.
  TreeNode getMax(TreeNode root, TreeNode currentMax, enum attribValue){
  if(root == null)
  return currentMax;
  if ((root->left.val == attribValue) && (root->left.val == attribValue)) {
  getMax(root->left, currentMax, attribValue);
  getMax(root->right, currentMax, attribValue);
  } else {
  getMax(root->left, root->left, attribValue);
  getMax(root->right, root->right,, attribValue);
  }
  }
  I have quite a simple answer to this question.
  OO design is how much detailed you can understand and segregate into difference objects while you plan to design the system. Also, it tests your ability to see if one object is related to another object and if so how?
  System Design is more abstract, you see it is more of how the over all architecture should be layed out, to make the service available. This goes back to the bigger picture of how much you are aware of the current development of frameworks. Example like, NoSQL vs RDMS and why, advantage of one architecture over another etc.
  Overall, in a nutshell, OO Design is detailed understandings and visualization of the system you are designing and system design is how you lay your architecture and provide high performing design
  My Algo is
  boolean find(String s){
  Map<String, Integer> map = new HashMap<String, Integer>();
  int maxRepeat = 0, noofChar = 0;
  for(char c: s.toCharArray()){
  if(map.containsKey(c)){
  int i = map.getVal(c);
  map.put(c, ++i);
  } else {
  map.put(c, 1);
  }
  }
  for(Map.EntrySet<String, Integer> entry: map.entrySet()){
  if(maxRepeat < entry.getValue()) maxRepeat = entry.getValue();
  noofChar++;
  }
  return ((noofChar / maxRepeat) > 1) ? true : false);
  }
  Why Sharing challenging questions isnt bad.. regardless of them being the real interview questions.
  I am not frequent in this site as I use to but I think this site is for sharing challenging interview questions and help prepare people
  I think this is pretty easy question, twoSum problem but the follow up could be killer.
  Determine if a number is a sum of any number of squares
  You are pushing to hard. You may lose offer if you don't have patience. BTW how the hell did they went with you when they don't even have an openings?
  Chances are getting slim for you and the way, your immaturity shinning up, suggest looking elsewhere
  This requires consideration amount of memcache experience to properly answer. Few of my options are
  1> Secondary Indexing, Where we let cache to know its existence and once hit, can redirect to where it is located.
  2> Serialization, storing raw bit value, and distributing to multiple cache location till it finds end of object.
  Both of the above process are generally used depending upon the requirements.
  I have seen a tons of response for this simple question. I dont think this question is intended to provide sorted square of integer inputs. Interviewer wanna check how much candidate knows about Integer implementation.
  As we square up high value integer, it wont fit in another integer so unless you come up with a custom class which able to do so, all above responses are wrong. Specially when a candidate is interviewing top companies
  Shame on you.. Cant even solve a question in 3 days and think you can make upto Dropbox?
  This is utter nonsense and learning curve for Dropbox recruiter to consider such junk candidate while rejecting quality people right outfront..
  Just wondering why do retard do such ad in here?
  Do they think, folks visits such urls from here? I mean I dont see the purpose or value?
  Use
  Map<Date, List<Integer>> map = new HashMap<Date, List<Integer>>
  Insert :
  List<Integer> songsId = map.get(currentDate);
  songsId.add(newSongId);
  map.add(currentDate, songsId );
  retrieve:
  for(Map::EntrySet<Date, List<Integer>> entry : map){
  if(DateWithinWeek( entry.getKey())){
  for(Integer songsId : entry.getVal){
  // output the result
  }
  }
  }
  @ChrisK,
  I got what you are saying, you are talking about for every update you have to call up the nodes to update it content.
  what if we always point a node.value to the value of a global variable? I'll try to give you a code later after work, but I think I can make it work.
  Career Cup is soo messed up, you cant update / delete your comments and sometimes it wont post what we have submitted making us to resubmit again ??
  @ChrisK
  Nope, I dont think you got it.
  Think you have a global / static variable holding a sum of all the node.value visited so far. Now each node has a function called updateOnWrite(); which updates it node.value if this global value changes it content. That what copy on write means, someone over written a value and you have to update you content.
  Each node updates it value independently.
  @ChrisK,
  Nope, I dont think you got what I suppose to mean.
  Think you are updating a static / global variable every time you visit a node and each Node has to update its value if the value of this global / static variable is changed, that what copy on write me. Someone has rewritten the data and your data is dirty forcing a node to update its content.
  Each node update its content independently.
  @ChrisK
  There are multiple ways to implement it.
  Design Patterns like observers can be used as well as you can set a reference of each node.data value to some common address and update that common memory location updating everynode while you calculate the total sum. Last value updated will be the value of all node.
  This is easy one, Same as height balance.
  Rather than increment by 1, you have to increment by the node->data
  You Can reduce to Single pass by using copy on Write and sharing the data object of each node but still it is O(n) solution.
  There is no way you can do it faster than that, as you must visit all nodes to get its content
  Whoever that negative Voter is, should be ashamed of yourself. I already have mentioned this question is to gather experience not to showcase your technical question, coz even if you got em aced, it doesn't look like folks are playing fair game..
  And you are one of em it seems same question with couple of addition twicks kicked me off Google round this January.. Very hard to understand question in 20 minutes... Never understood question in sweaty 20 minute
  True Collar... ROFL.. I think he meant True Caller..
  Well you can use Map.
  Map<String, String> map = new HashMap<String, String>();
  Which maps, Any number (converted to String) to username in String
  It will be hardcore coding rounds. Amazon test even for tester using complex algorithms. Once you cleared these initial coding round, you may be tested with your BA skills in their corresponding interview rounds.
  Free hand code, O(n) space and time
  boolean isUnique(String str){
  Map<Character, Boolean > map = new HashMap<String, Boolean>;
  for(Character c : str.toCharArray()){
  if(map.ContainsKey(c)){
  return false;
  } else {
  map.put(c);
  }
  return true;
  }
  Yes you can.. It is same as using normal cycle detection with set concept.
  Algo,
  For each node in a graph {
  if(Find(parent, parent->child[index])){
  Cycle detected
  } else {
  Union(Set, parent, parent->child[index])
  }
  }
  Load balancing is what interviewer is looking for but its ambiguous when he says "Slow".It can be any from a broad spectrum.
  If its getting slow relative to its earlier performance than it varies from network speed to amount of space / resources available at server end.
  In terms of codes, the best you can do is limiting the use of thread by threadpooling. meaning, you can spawn specific number of threads at a time so that it wont hog the system doing nothing but scheduling.
  Very interesting question. Interviewer is definitely looking for brainstorming and may be he will jump in it as well.. Love such rounds..
  There is no definite answer to this question, but my approach is as follows
  class BlockChain{
  HashValue;
  Deltas;
  TimeStamp;
  }
  class Auth{
  string userName;
  string repository;
  // Other params
  }
  Now git is distributed system but its not fully distributed. If git were to be fully distributed, things will blow pretty fast and gonna be even complex.. So
  class Server{
  Auth m_Auth;
  List<BlockChain> m_blockChains;
  //other parameters
  }
  class Client {
  Auth m_auth;
  List<BlockChain> m_blocks;
  BlockChain m_currentSession;
  //Rest of the params
  }
  Now the methods for each classes are very much depends on how / what functions git supports
  How the hell it is a decorator ? Explain.. coz this is a classic example of Command design pattern.
  Reason is it is command coz you can configure what slots goes to what denomination of currency and how many denomination can be arranged when we set the ATM machine object.
  This also, employs State design pattern, coz every time, you do the operation, you will change the state of machine.
  Can share the code if required but will be messy in such question coz its purely a discussion based.
  I dont know how you people gets so lucky man ?
  When I got a call from them, my question is so vague that I waste my 40 minute to get hold of it and still wasn't sure if I was doing it correct losing all the time.
  So, answering this part as follows.
  int generateRandon(int size){
  int dp[][] = int [size +1 ][size +1];
  for(int x = 0; x < size; x++){
  for(int y =0; y < size; y++){
  int rand = Math.random(LOWER, HIGHER); // rewrite this custom random
  if(x>0 || y > 0){
  int valX = dp[x-1][y];
  int valY = dp[x][y-1];
  if((rand == valX) || (rand == valY)){
  y--; continue;
  } else {
  dp[x][y] = rand;
  }
  }
  }
  }
  return dp;
  }
  bool check(int a[])
  {
  int a = a[0];
  int b = a[1];
  int gcd = gcd(a, b);
  int prime = 0;
  if(!isPrime(gcd))
  {
  prime = Prime(gcd);
  }
  else
  {
  prime = gcd;
  }
  for(int i = 2 ; i < a.length - 1; i++){
  if(a[i] % prime != 0){
  return false;
  }
  }
  return true;
  }
  void findClosest(int n)
  {
  double sq = Math.sqrt(n);
  if((Math.floor(sq) * Math.ceil(sq) >= n))
  cout<< Math.floor(sq) << Math.ceil(sq)<<endl;
  else
  cout<< (Math.floor(sq) -1) << Math.ceil(sq)<<endl;
  }
  This is a design pattern question..
  Really a google question ?
  Plain O(n).
  Collect all char in a hash.
  For each char in hash
  if(hash.containsKey(char) > 1){
  put that char in new string, i & strlen(str) - i position
  update hash.add(char , (hash.containsKey(char) - 2))
  } else {
  int val = hash.get(char);
  hash.add(char, hash.containsKey(char) - 1);
  if(!hash.isempty()){
  Error:-> Cannot be formed
  }
  }
  Any memory layout explanation fits the output but understanding it seems complex. So here it is..
  When you create derived object, base class object is created before derived class object. When you stack them one over other and try to access it with variable base address, the complier has no clue which one is variable "a" or "b".
  So what it does is with respect to the current base address, it tries to access the member. So in your case.
  (obj + 0) = Address of arrd as base address of object
  (obj + 1) = Address of arrd + 4 byte (as your base class has 1 integer variable). Base address of object
  Interestingly here, when you do (obj + 1)->getA(), complier access the first integer wrt its current base which unfortunately is the variable "b" of derived class for you.So it this output.
  Ambitious question,
  Not able to find the relationship between the question you posted and the example you cited, how is 7->1 not in the list. Are you talking about user visiting pages relationship or the order in which the user is visiting the pages relationship question on the floor?
  There will always be a event driven function like
  void onChange(){
  double dis = distance(myPos, newPos);
  if(dis < leastDistance(listOfClosePoints)){
  removeMinfromList(listOfClosePoints)
  listOfClosePoints.add(newPos);
  }
  }
  One possible solution is
  #1
  1> Find all the palindromes in the stream.
  2> For each palindrome in the list
  if(hash.containsKey(palidrome)){
  hash.add(palindrome, hash.getValue(palindrome) + 1);
  } else {
  hash.add(Key, 1);
  }
  3> Find the max count in the hash and print that key.
  #2,
  Prefix Array calculation in KMP algorithm could be used
  As each prefix array is the suffix of the current string, the value will give the solution in minimum time and space complexity
  You got excelling question asked Lively, Which organization and where ? Are you Fresh graduate, It seems questions are directed towards your academics and logics.
  You know what this can be an excellent question. I am not sure even interviewer thought to be that one. This actually is a palindrome question. Here is how.
  The question is not to balance a parenthesis, which an be debatable coz any combination can give you balance expression.
  So, how do you resolve this problem, is parse all string except braces and replace with common character. Ex. (a(b(c)de will become (x(x(x)xx.
  Now, what it takes to convert this expression into palindrome is the question. I am sure may can now answer without further hints .
  Gayle 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 ... ...
  The only certain answer to this question is BFS.- hprem991 January 02, 2019
  From the start node, you have to scan all path and as we traverse down till we either reach the end node or flag it false for when you have checked all nodes.