@sharing-account I thought we cannot perform direct int operations
like return int(s1)*int(s2).However thanks for pointing out I have now edited my code.
If there are still any concerns feel free to point out
Posts made by sankalp6
Share my O(n) Time and O(1) space python solution With Comments
def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ prevmax=float('-inf') prevmin=float('inf') maxprofit=0 for i in range(0,len(prices)): if prices[i]<prevmin:#if A[i] less than previously found minimum we will update both max and min tiil now to A[i] prevmin=prices[i] prevmax=prices[i] elif prevmax<prices[i]:# if A[i] is greater than prevmax we will update prevmax prevmax=prices[i] maxprofit=max(maxprofit,prevmax-prevmin) return maxprofit