我正在进行编码挑战,每次提交时我都会得到一个错误的答案,并显示“ stdout无响应”。您知道我能做什么吗?这是问题的链接:https://www.hackerrank.com/challenges/counting-valleys/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=warmup
def countingValleys(n, s):
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
s = input()
result = countingValleys(n, s)
fptr.write(str(result) + '\n')
fptr.close()
N=int(input())
S = input()
L = 0
V = 0
for el in S:
if s == 'U':
L+= 1
if L == 0:
V += 1
else:
L -= 1
print(V)
答案 0 :(得分:0)
您可能正在返回值,而不是使用print()
函数。问题规范说您必须打印它。