본문 바로가기

알고리즘39

[Kotlin] Leetcode 35. Search Insert Position Problem Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [1,3,5,6], target = 5 Output: 2 Example 2: Input: nums = [1,3,5,6], target = 2 Output: 1 Example 3: Input: nums = [1,3,5,6], ta.. 2022. 1. 24.
[Kotlin] Leetcode 278. 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 after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be.. 2022. 1. 20.
[Kotlin] Leetcode 704. Binary Search Problem 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. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [-1,0,3,5,9,12], target = 9 Output: 4 Explanation: 9 exists in nums and its index is 4 Example 2: Input: n.. 2022. 1. 20.
Leetcode로 배우는 Kotlin 알고리즘 코딩테스트 시험 대비 Algorithm 1 Day 1 Binary Search 704. Binary Search 278. First Bad Version 35. Search Insert Position Day 2 Two Pointers 977. Squares of a Sorted Array 189. Rotate Array Day 3 Two Pointers 283. Move Zeros 167. Two Sum II - Input Array Is Sorted Day 4 Two Pointers 344. Reverse String 557. Reverse Words in a String III Day 5 Two Pointers 876. Middle of the Linked List 19. Remove Nth Node From End o.. 2022. 1. 19.
300x250