mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-24 13:31:07 +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
|
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
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user