Algorithm/Binary Search (44) 썸네일형 리스트형 (Python3) - 백준(BOJ) 1561 : 놀이 공원 https://www.acmicpc.net/problem/1561이분 탐색 문제였습니다.📕 풀이방법📔 입력 및 초기화탑승자 아이들의 수 child, 놀이기구 수 attractions, 각 놀이기구별 탐승시간 ride_times선언 후 입력 받습니다.📔 풀이과정무엇에 대해 이분탐색을 해야하는지 찾기가 쉽지 않았습니다. 처음 탑승할 아이의 수가 많기 때문에 그 숫자에 힌트를 얻어 아이에 대해 이분탐색을 진행했으나 각 놀이기구마다 탐승 가능한 아이의 수가 제각각 다르기 때문에 반대로 특정 시간(last_time)이 지났을 때 누적된 탑승자 수가 입력 받은 child값과 일치하는지 확인하는 방식으로 접근해야합니다. 1. 이분 탐색을 진행해줍니다. 1-1. left와 right변수를 설정해 시간을 이.. (C++, Rust) - LeetCode (easy) 222. Count Complete Tree Nodes https://leetcode.com/problems/fair-candy-swap/description/ Fair Candy Swap - LeetCode Can you solve this real interview question? Fair Candy Swap - Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice h leetcode.com 이분탐색 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. alice 가 .. (C++) - LeetCode (easy) 744. Find Smallest Letter Greater Than Target https://leetcode.com/problems/find-smallest-letter-greater-than-target/description/ Find Smallest Letter Greater Than Target - LeetCode Can you solve this real interview question? Find Smallest Letter Greater Than Target - You are given an array of characters letters that is sorted in non-decreasing order, and a character target. There are at least two different characters in letters. Retu leetc.. (C++) - LeetCode (easy) 704. Binary Search https://leetcode.com/problems/binary-search/description/ Binary Search - LeetCode Can you solve this real interview question? Binary Search - Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. leetcode.com 이분탐색 문제였습니다. 📕 풀이방법 📔 풀이과정 target이상의 iterator를.. (C++) - LeetCode (easy) 455. Assign Cookies https://leetcode.com/problems/assign-cookies/description/ Assign Cookies - LeetCode Can you solve this real interview question? Assign Cookies - Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g[i], which is the minimum size o leetcode.com greedy 또는 이분탐색으로 푼 문제였습니다. 📕 풀이방법 📔 입력 및 초기화.. (C++) - LeetCode (easy) 278. First Bad Version https://leetcode.com/problems/first-bad-version/description/ First Bad Version - LeetCode First Bad Version - You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions leetcode.com 이분 탐색 문제였습니다. 📕 풀이방법 📔 풀이과정 처음으로 isBadV.. (C++) - LeetCode (easy) 374. Guess Number Higher or Lower https://leetcode.com/problems/guess-number-higher-or-lower/ 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 이분탐색 문제였습니다. 📕 풀이방법 📔 풀이과정 1. 1초는 1억연산이므로 n이 2^31승인 경우 O(n) 인 시간복잡도를 가지는 brute force로 해결할 수 없습니다. O(logn)인 이분탐색을 사용해야합니다. 2. 1 ~ n-1까지의 범위를 이분탐.. (C++) - LeetCode (easy) 35. Search Insert Position https://leetcode.com/problems/search-insert-position/ Search Insert Position - 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 이분탐색 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 target이상의 값이 나온 원소의 iterator를 lower_bound함수를 이용해 구해줍니다. 이 값을 지역변수 idx 선언 후 저장합니다. 📔 풀이과정 1. target이상의 값이 num에 없으면 lower_boun.. 이전 1 2 3 4 ··· 6 다음