diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..615aafb03 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/usr/bin/python3" +} \ No newline at end of file diff --git a/data_structures/Stacks/Stock-Span-Problem.py b/data_structures/Stacks/Stock-Span-Problem.py index 658ac3cbf..9628864ed 100644 --- a/data_structures/Stacks/Stock-Span-Problem.py +++ b/data_structures/Stacks/Stock-Span-Problem.py @@ -1,11 +1,12 @@ ''' The stock span problem is a financial problem where we have a series of n daily -price quotes for a stock and we need to calculate span of stock’s price for all n days. +price quotes for a stock and we need to calculate span of stock's price for all n days. -The span Si of the stock’s price on a given day i is defined as the maximum +The span Si of the stock's price on a given day i is defined as the maximum number of consecutive days just before the given day, for which the price of the stock on the current day is less than or equal to its price on the given day. ''' +from __future__ import print_function def calculateSpan(price, S): n = len(price) @@ -37,7 +38,7 @@ def calculateSpan(price, S): # A utility function to print elements of array def printArray(arr, n): for i in range(0,n): - print arr[i], + print (arr[i],end =" ") # Driver program to test above function @@ -48,4 +49,4 @@ S = [0 for i in range(len(price)+1)] calculateSpan(price, S) # Print the calculated span values -printArray(S, len(price)) \ No newline at end of file +printArray(S, len(price))