컴퓨터공학/알고리즘 문제 풀이 35

[LeetCode] 278. First Bad Version

https://leetcode.com/problems/first-bad-version/ 피봇을 사용하여 탐색하는 문제입니다. First Bad Version - LeetCode Can you solve this real interview question? 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 base leetcode.com 솔루션 # The isBadVersion API is..

[LeetCode] 205. Isomorphic Strings

제 3의 문자열로 표현하여 문제를 해결할 수 있습니다. https://leetcode.com/problems/isomorphic-strings/ Isomorphic Strings - LeetCode Isomorphic Strings - Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving th leetcode.com 솔루션 class Solutio..

[LeetCode] 167. Two Sum II - Input Array Is Sorted

Two pointer 알고리즘을 활용하여 시간복잡도가 O(n) 이내가 되도록 문제를 풀어야 합니다. 본문 https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/ Two Sum II - Input Array Is Sorted - LeetCode Two Sum II - Input Array Is Sorted - Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers..

[LeetCode] 438. Find All Anagrams in a String

Sliding Window 알고리즘과 HashMap (파이썬에서는 dictionary로 구현) 자료구조에 대한 이해가 필요한 문제였습니다. https://leetcode.com/problems/find-all-anagrams-in-a-string 문제 핵심 일반적인 반복문 또는 Two pointer 기법을 사용하면 time limit 따라서 계산 횟수를 최소화 하는 기법을 사용해야 함 Two pointer 알고리즘과 비슷한 Sliding Window 알고리즘을 사용해야 한다 두 개의 해쉬맵을 만들어 계산을 간소화 솔루션 class Solution: def findAnagrams(self, s: str, p: str) -> List[int]: s_length, p_length = len(s), len(p)..