Merge pull request #407 from s-sanyal/master

Made the code Python 3 compatible
This commit is contained in:
Harshil 2018-10-04 11:37:12 +02:00 committed by GitHub
commit c8e7a65475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.pythonPath": "/usr/bin/python3"
}

View File

@ -1,11 +1,12 @@
''' '''
The stock span problem is a financial problem where we have a series of n daily 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 stocks 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 stocks 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 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. 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): def calculateSpan(price, S):
n = len(price) n = len(price)
@ -37,7 +38,7 @@ def calculateSpan(price, S):
# A utility function to print elements of array # A utility function to print elements of array
def printArray(arr, n): def printArray(arr, n):
for i in range(0,n): for i in range(0,n):
print arr[i], print (arr[i],end =" ")
# Driver program to test above function # Driver program to test above function
@ -48,4 +49,4 @@ S = [0 for i in range(len(price)+1)]
calculateSpan(price, S) calculateSpan(price, S)
# Print the calculated span values # Print the calculated span values
printArray(S, len(price)) printArray(S, len(price))