알고리즘1 [Python] 기초 알고리즘 문제 풀이 [Python] 기초 알고리즘 문제 풀이초보자를 위한 기본적인 알고리즘 문제와 해결 방법을 Python 코드로 살펴보자. 순차 탐색기본 순차 탐색def sequential_search(arr, target): for i in range(len(arr)): if arr[i] == target: return i # 찾은 위치 반환 return -1 # 못 찾은 경우# 사용 예시numbers = [4, 2, 7, 1, 9, 3]result = sequential_search(numbers, 7)print(f"위치: {result}") # 위치: 2 문자열에서 문자 찾기def find_all_positions(text, char): positions = [].. 2024. 11. 27. 이전 1 다음