Question: only python Net Gain Function Name: netGain() Parameters: buy and sell history (str) Returns: net gain (int) Description: You've bought and sold a particular stock
only python
Net Gain Function Name: netGain() Parameters: buy and sell history (str) Returns: net gain (int) Description: You've bought and sold a particular stock several times, and want to know your net gain. You have a string of bs and ss that represent your history of buying and selling. A b represents buying a stock at the price of the inde at which it occurs in the string. Simi- larly, an s represents selling a stock at the price of the index at which it occurs in the string. Find and return the total gain or loss of stocks by subtracting the sum of the indices of b s from the sum of indices of s s. >>> netGain("bbbsss") 9 >>> netGain("bsbsbs") 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
