투 포인터

#투 포인터

백준 2003번 : 수들의 합 2

1. 단순 반복문 풀이

count, sum=list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))

counting=0
temp=0

for i in range(count):
  temp=0
  for j in range(i, count):
    temp=temp + a[j]
    if(temp==sum):
      counting=counting+1
      break
    elif(temp>sum):
      break

print(counting)

2. 투 포인터 풀이

Last updated