Skip to content

Commit c8e7a65

Browse files
authored
Merge pull request TheAlgorithms#407 from s-sanyal/master
Made the code Python 3 compatible
2 parents caea476 + 63c7e8e commit c8e7a65

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "/usr/bin/python3"
3+
}

data_structures/Stacks/Stock-Span-Problem.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'''
22
The stock span problem is a financial problem where we have a series of n daily
3-
price quotes for a stock and we need to calculate span of stocks price for all n days.
3+
price quotes for a stock and we need to calculate span of stock's price for all n days.
44
5-
The span Si of the stocks price on a given day i is defined as the maximum
5+
The span Si of the stock's price on a given day i is defined as the maximum
66
number of consecutive days just before the given day, for which the price of the stock
77
on the current day is less than or equal to its price on the given day.
88
'''
9+
from __future__ import print_function
910
def calculateSpan(price, S):
1011

1112
n = len(price)
@@ -37,7 +38,7 @@ def calculateSpan(price, S):
3738
# A utility function to print elements of array
3839
def printArray(arr, n):
3940
for i in range(0,n):
40-
print arr[i],
41+
print (arr[i],end =" ")
4142

4243

4344
# Driver program to test above function
@@ -48,4 +49,4 @@ def printArray(arr, n):
4849
calculateSpan(price, S)
4950

5051
# Print the calculated span values
51-
printArray(S, len(price))
52+
printArray(S, len(price))

0 commit comments

Comments
 (0)