Sunday, 29 September 2019

Interview at Reliance Jio

Round 1:
  • Print 1000 random numbers of single digit each. Number should be between 0 to 9.
  • Store the above elements in a array and move all the 0s into one end without changing the order of non-zero elements.
  • Find out the top 50 elements in a stream of 1000 elements. Assume that numbers are streaming and you don't know the size ahead. and if you want to know the frequency of the top 50 elements also, how would you do? Hint: Heap
  • Assume that you can only send 160 characters in one message. If you have a paragraph to send, how do you determine that and send it over network, every page should send which part the message it is, like [1/2]. Hint: Travese entire message first to determine whether there are multiple messages possible.

Round 2:
  • Given array of integers, find out the first non-repeating element.
  • Given M*N matrix of Integers, find out the area covered between 2 cells.
  • Convert a doubly linked list into binary tree.

Round 3:
  • Diff between SOAP and REST APIs.
  • Given a src and dest vertex in a graph, write a method to return true if dest can reachable all possible paths from the src vertex. There can any number of intermediate vertices.
  • [Puzzle] 4 persons of diff speeds need to cross a bridge with one torch where only two can travel at a time from the bridge, what is the minimum time that they take to reach all on the other side. How can you solve this generically.

Wednesday, 11 September 2019

[System Design] Scaling methodologies

Wikipedia says, Scalability is the property of a system to handle a growing amount of work by adding resources to the system. With increase in customer demand, Servers hit the scale problems. There are 2 standard ways of handling the Scalability.
1. Horizon Scaling: Add more servers/Machines when there is a increase in load.
  • Demands load balancing to balance client requests.
  • Results in distributed systems and possible data inconsistency.
2. Vertical Scaling: Add more resources to the same server.
  • Single server holds all the data and hence there will be no data consistency issues.
  • Will result in better IPC as things are local to single server.
  • Can result in Single Point of failure.
  • Cannot go beyond certain hardware limits.

In practical, it is better to use a combination of both to achieve better results. Perform the Vertical scaling and move to Horizontal scaling after some peek limits.