Amit Gupta
BAN USER
Comments (2)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
We can implement this scenario with an observer pattern. The observed object taking in the number of stocks to be bought. The same object will also maintain a list of observers (the exchanges so to say). As soon as the observed object receives a buy order of say n stocks, it will notify all observers (stock exchanges), which in return will return the best selling price from them. This price can be compared at the observed object's end and the first order can be executed at the exchange offering the best selling (lowest) price. Do this recursively for n number of orders and your entire buy order will be executed at the lowest price. You can perform the same scenario for a sell order of n stocks as well.
- Amit Gupta October 20, 2016Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
One can use API's like Scanner from the java.util package. This API doesn't keeps references to data one is has been read from the file and as such its memory footprint compared to conventional file reading API's like BufferedReader is very less. Good for reading huge files as such.
- Amit Gupta June 19, 2017