Skip to content

Commit 692d663

Browse files
authored
Merge pull request #94 from zaqquum/main
Hongjoo/11월 3주차 / 3문제
2 parents c123b12 + 2a94274 commit 692d663

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

Hongjoo/lv2/숫자의표현.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'''
2+
[문제] : https://school.programmers.co.kr/learn/courses/30/lessons/12924#
3+
[Flow]
4+
연속된 자연수의 조합-> two point
5+
0. 초기화
6+
start == end-1 = 0
7+
while end <= len(words) and start < end
8+
1. sum(words[start,end]) < target
9+
-> end += 1
10+
2. sum(words[start,end]) == target
11+
-> count += 1
12+
-> start += 1
13+
-> end = start +1
14+
15+
3. sum(words[start,end]) > 0
16+
-> 2와 동일
17+
18+
'''
19+
def solution(n):
20+
answer = 1 # 본인= target
21+
start = 0 ; end = start +1 ;
22+
answer_li = []
23+
half= round(n//2) +2
24+
field = range(1,half) # 반올림
25+
field = list(field)
26+
27+
while n > 2 and end <= len(field) and start < end and start < len(field): #
28+
current =sum(field[start : end])
29+
if current < n :
30+
end += 1
31+
else : # currnet >= n
32+
if current == n :
33+
answer += 1
34+
answer_li.append([start, end])
35+
start += 1
36+
end = start +1
37+
return answer

Hongjoo/백준/문자열교환.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
words= input()
66
window_size = words.count("a") # 1. a의 개수 = sliding window 크기
7-
result = 999999999
7+
result = 99999999
88

99
# 원형 문자열
1010
words += words[0:window_size-1]
1111
# 2. 최대한 a 가 연속해 있는 idx 범위 찾기
1212
for start in range(len(words) - (window_size-1)):
1313
result = min(result, words[start: start+ window_size].count("b"))
1414

15-
print(result)
15+
print(result)
16+

Hongjoo/백준/부분합.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"""
2+
문제 : # 1806부분합
23
https://www.acmicpc.net/problem/1806
4+
5+
해설 :
6+
https://aia1235.tistory.com/46
7+
38
"""
49
import sys
510
N ,S = map(int, sys.stdin.readline().split())
@@ -17,11 +22,11 @@
1722
end += 1
1823
if end < N :
1924
partial_sum += arr[end]
20-
else : # 수열 끝 -> 조건 충족 x
25+
else : #반복문 끝
2126
break
2227

2328

24-
if min_length == 100000 :
29+
if min_length == 100000 : # 수열 끝 -> 조건 충족 x
2530
print(0)
2631
else :
2732
print(min_length)

0 commit comments

Comments
 (0)