Code&Data Insights
BaekJoon Algorithm - Stage 1 ~ 7 [Review] 본문
BaekJoon Algorithm - Stage 1 ~ 7 [Review]
paka_corn 2022. 1. 18. 06:562022.01.20
지금까지 어려웠던 & 틀렸던 문제 다시 풀어보기
[10871]
[my code]
n,x = map(int, input().split())
arr = []
for i in range(n):
i = int(input())
if i < x:
arr.append(i)
print(set(arr))
----> 출력은 제대로 됐지만 런타임에러가 났다.
[new code]
n,x = map(int, input().split())
arr = list(map(int,input().split()))
for i in range(n):
if arr[i] < x:
print(arr[i],end=' ')
---------------------------------------------------------
[1110]
[my code]
n = int(input())
cnt = 0
while True:
a = (n//10) + (n % 10)
b = ((a % 10)*10) + (a%10)
cnt += 1
if b == n:
break
print(cnt)
---> 시간초과가 떴다.
[new code]
n = int(input())
num = n
cnt = 0
while True:
a = num // 10
b = num % 10
c = (a+b)%10
num = (b*10) + c
cnt += 1
if (num == n):
break
print(cnt)
--> 코드 조금 다른데 왜 이건 시간초과 안나냐 어이없음..
---------------------------------------------------------
[8958]
[my code]
n = int(input())
for i in range(n):
x = input()
sum = 0
cnt = 0
for j in range(len(x)):
if (x[j] == 'O'):
cnt += 1
sum += cnt
else:
cnt = 0
print(sum)
---------------------------------------------------------
[1157]
[my code]
word = input().upper()
al_list = list(set(word))
al_cnt = []
for i in al_list:
count = word.count(i)
al_cnt.append(count)
if al_cnt.count(max(al_cnt)) > 1:
print("?")
elif al_cnt.count(max(al_cnt)) == 1:
freq_letter = al_cnt.index(max(al_cnt))
print(al_list[freq_letter])
--> 다시 풀어도 어렵군...
---------------------------------------------------------
[2941]
[my code]
c = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z=']
w = input()
for i in c:
w = w.replace(i,'c')
print(len(w))
*** replace() ***
---------------------------------------------------------
[1316]
[my code]
n = int(input())
cnt = n
group_word = 0
for i in range(n):
w = input()
for j in range(len(w)-1):
if w[j] == w[j+1]:
pass
elif w[j] in w[j+1:]:
cnt -= 1
break
print(cnt)
The pass statement is used as a placeholder for future code. When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not allowed.
[ 문자열 슬라이싱 ]
[ 총평 ]
좀만 더 인내심과 시간을 가지고 더 깊게 파보자..!
복습한 문제들은 어려워서 구글링한 것이 많아서 다음주 복습할때
한번씩 다시 풀자!
'Algorithm > BaekJoon Online Judge' 카테고리의 다른 글
BaekJoon Algorithm - Stage 10 [10872,10870] ( Python 3 / JAVA ) (0) | 2022.01.23 |
---|---|
BaekJoon Algorithm - Stage 8 [1712, 2869] ( Python 3 ) (0) | 2022.01.18 |
BaekJoon Algorithm - Stage 7 [ 5-10 ] ( Python 3 ) (0) | 2022.01.18 |
BaekJoon Algorithm - Stage 6[1], Stage 7 [ 1-4 ] ( Python 3 ) (0) | 2022.01.16 |
BaekJoon Algorithm - Stage 5 [ 4-7 ] ( Python 3 ) (0) | 2022.01.15 |