mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-24 05:21:09 +00:00
Merge pull request #407 from s-sanyal/master
Made the code Python 3 compatible
This commit is contained in:
commit
c8e7a65475
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"python.pythonPath": "/usr/bin/python3"
|
||||
}
|
|
@ -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))
|
||||
printArray(S, len(price))
|
||||
|
|
Loading…
Reference in New Issue
Block a user