Zero to Hero
article thumbnail
1829. Maximum XOR for Each Query
Algorithm 2021. 9. 4. 11:04

Maximum XOR for Each Query - 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 조건에 대한 범위의 모든 음이 아닌 정수들을 XOR 연산한 후의 값을 A라고 한다면, A XOR B = 2진수 maximumBit 길이의 가장 큰 값을 만족하는 B를 구해 반환하는 문제다. 예시 maximumBit = 2 인 경우, 조건에 맞는 범위의 모든 정수 값을 XOR 연산한 값이 1 이라고 한다면 1 ^ B = 길이 2의 가장 큰 이진수 = 11(2) = 3..

article thumbnail
1641. Count Sorted Vowel Strings
Algorithm 2021. 9. 2. 15:59

Count Sorted Vowel Strings - 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 양의 정수 N이 주어질 때, 알파벳 소문자 모음 5개로 길이 N의 문자열을 만들고 그 가짓수를 반환한다. 이때 문자열을 구성하는 문자들은 사전 순으로 오름차순 정렬돼있는 문자열만 인정한다. 예시 Input: n = 1 Output: 5 Explanation: The 5 sorted strings that consist of vowels only are ["a","e..

article thumbnail
1657. Determine if Two Strings Are Close
Algorithm 2021. 9. 1. 13:58

Determine if Two Strings Are Close - 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 문자열 2개가 주어지고, 문자열을 조작할 수 있는 방법 2가지가 주어진다. 해당 방법을 이용해 두 문자열의 관계를 애너그램(anagram)으로 만들 수 있는지 유무를 반환하는 문제다. 조작법 2가지 Operation 1: Swap any two existing characters. For example, abcde -> aecdb Operation 2..

article thumbnail
1261. Find Elements in a Contaminated Binary Tree
Algorithm 2021. 8. 31. 19:26

Find Elements in a Contaminated Binary Tree - 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. root.val == 0 2. If treeNode.val == x and treeNode.left != null, then treeNode.left.val == ..

article thumbnail
890. Find and Replace Pattern
Algorithm 2021. 8. 30. 12:00

Input: words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb" Output: ["mee","aqq"] Explanation: "mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}. "ccc" does not match the pattern because {a -> c, b -> c, ...} is not a permutation, since a and b map to the same letter.​ Find and Replace Pattern - LeetCode Level up your coding skills and quickly land a job. T..

article thumbnail
95. Unique Binary Search Trees II
Algorithm 2021. 8. 29. 13:30

Unique Binary Search Trees II - 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 정수 n이 주어진다. 1 ~ n의 값을 가지는 노드로 구성된 만들 수 있는 모든 이진 탐색 트리를 반환하는 문제다. n = 3 TreeNode(1), TreeNode(2), TreeNode(3)의 총 3개의 노드를 이용해 만들 수 있는 이진 탐색 트리는 총 5가지다. 여기서 중요한 점은 갯수가 아니라 트리를 반환해야하는 거고, 그러니깐 진짜 트리를 만들어서 반..