binarysearch

개발공부/algorithm

[Leetcode][python] 374. Guess Number Higher or Lower - Binary Search

Problem Leetcode 374. Guess Number Higher or Lower - Binary Search Level: Easy Link Guess Number Higher or Lower - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com My Code 기본적인 Binary Search 문제이다. n = 2, pick = 2, n=1, pick 1 처럼 interval이 얼마 차이 나지 않는 경우들에 대한 조건처리가 잘 되어야 한다. # The gu..

개발공부/algorithm

[leetcode][python] 278. First Bad Version - Binary Search

Problem Leetcode 278: First Bad version Level: Easy Link First Bad Version - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com My Code 기본적인 이진탐색 문제다. 이진 탐색을 진행해주며 가장 먼저 발생하는 bad version을 체크해준다. # The isBadVersion API is already defined for you. # @param version, an integer # @return ..

개발공부/algorithm

[백준][python] 1806.부분합 - 이분탐색

백준 1806 부분합 Gold IV 문제링크 1806번: 부분합 첫째 줄에 N (10 ≤ N < 100,000)과 S (0 < S ≤ 100,000,000)가 주어진다. 둘째 줄에는 수열이 주어진다. 수열의 각 원소는 공백으로 구분되어져 있으며, 10,000이하의 자연수이다. www.acmicpc.net 나의 코드 N, S = map(int, input().split()) A = list(map(int, input().split())) sum_A = [0] * (N + 1) for i in range(1, N + 1): sum_A[i] = sum_A[i-1] + A[i-1] answer = 1000001 start = 0 end = 1 while start != N: if sum_A[end] - sum_..

so.py
'binarysearch' 태그의 글 목록