Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,177 views
in Interview-Experiences by Expert (34,270 points) | 1,177 views

1 Answer

0 like 0 dislike
  1. Currency Exchange: a list of currency relationships with exchange values. (BTC - USD) find the best exchange rate from currency1 to currency2. (https://leetcode.com/discuss/interview-question/1335225/Find-best-exchange-rate-from-currency1-to-currency2)

 

There is no possiblility of arbitrage.

 

It's a really hard problem in my opinion for a 45-min interview! First you need to create a graph with the exchange rate as the edge weight. Whatever path that gives you the higher value when multiplying the edges is your solution. First you need to convert the problem to a shortest path problem. To do so:

 

  • Instead of finding the value of E1 x E2 x E3 ... and find the path with max value, find the max value for
    log(E1 x E2 x E3 ...) = log(E1) + log(E2) + log(E3) + ...
  • We are looking for the minimum value so we multiply each edge by -1. Now we are looking for a min value for
    -log(E1 x E2 x E3 ...) = -log(E1) - log(E2) - log(E3) - ....
  • After making edges negative and take a logarithm we have a shortest path problem with negative edges. Dijkstra doesn't work so we need to apply Bellman-Ford algorithm.
  1. Connect 4 game. Follow up: Optimize it so that we find the best colum to drop the coin.

 

System Design: Design a trading system

 

IC5 US

by Expert (34,270 points)

Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .