📙
python-algorithm
  • 🖋️알고리즘 풀이 저장소
  • 이론
    • BFS & DFS 이론
    • 다익스트라 이론
    • 최소신장트리(크루스칼) 이론
    • 백트래킹 이론
  • 유형
    • 정렬
    • 순열과 조합
    • 탐색
    • 이분 탐색
    • SHA-256
    • 투 포인터
    • 피보나치
    • Z 재귀함수
    • 재귀함수
    • 친구 네트워크
    • 찾기
    • 큐
    • 스택 수열
    • 기하학
    • 트리 순회
    • 고급 탐색
    • BFS & DFS 알고리즘
    • 다익스트라 알고리즘
    • 최소신장트리(크루스칼) 알고리즘
    • 동적 프로그래밍
    • 그리디 알고리즘
    • 백트래킹 알고리즘
  • 기타
    • 베스트셀러
    • 성
    • 키 로거
    • 음계
Powered by GitBook
On this page
  • 백준 1543번 : 문서 검색
  • 1. 풀이
  • 백준 1568번 : 새
  • 1. 풀이
  • 백준 1668번 : 트로피 진열
  • 1. 풀이
  1. 유형

탐색

#문자열 #그리디 알고리즘 #브루트포스 알고리즘

백준 1543번 : 문서 검색

1. 풀이

data=input()
word=input()

i=0
result=0
while i<len(data)-len(word)+1:
  if(data[i:len(word)+i]==word):
    result=result+1
    i=i+len(word)
  else:
    i=i+1

print(result)

백준 1568번 : 새

1. 풀이

bird=int(input())

i=1
time=0

while bird>0:
  if(bird<i):
    i=1
  bird=bird-i
  time=time+1
  i=i+1

print(time)

백준 1668번 : 트로피 진열

1. 풀이

n=int(input())

arr=[]

for _ in range(0,n):
  size=int(input())
  arr.append(size)

left_count=1
right_count=1

left_max=0
right_max=0
for i in range(0,len(arr)-1):
  if(i==0):
    left_max=arr[i]
  if(arr[i+1]>left_max):
    left_count+=1
    left_max=arr[i+1]

arr.reverse()

for i in range(0,len(arr)-1):
  if(i==0):
    right_max=arr[i]
  if(arr[i+1]>right_max):
    right_count+=1
    right_max=arr[i+1]

print(left_count)
print(right_count)
Previous순열과 조합Next이분 탐색

Last updated 3 years ago