The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 364 Weeks Ago, 2 Days Ago |
| Questions Answered: | 1850 |
| Tutorials Posted: | 1850 |
Graduate in Biology and Nutrition, MBA Finance
Florida State University
Aug-2000 - Jul-2007
Ass. Relationship Manager
Penn-Florida
Mar-2009 - Feb-2016
You should save the solution to this problem in a file called maxprofit.py if you wish to use the tester program. write a function called maxprofit that accepts a single list argument as input (referred to as mylist in this description). The function should determine the maximum profit that can be made by 'buying' a stock at one index in mylist and 'selling' it at a later index. In this case, you can calculate the profit of buying at index x and selling at index y as mylist[y] - mylist[x]. Note that the selling index must come after the buying index. Your function must return a list with the following 3 pieces of information: the buy index, the sell index, and the maximum profit. You may assume
Â
Â
that at least one combination of buy/sell prices that exist produce a positive profit. You can also assume that there will be only one maximum combination (i.e., no ties exist).
Â
I wrote my code done but couldnt get the right answer through testfile can you check it for me ty:)
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- -----------Tha-----------nk -----------you----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m Â----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I