[LeetCode] 2425. Bitwise XOR of All Pairings (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. There exists another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 is paired with every integer in nums2 exactly once). Return the bitwise XOR of all integers in nums3. 문제 예제Example 1:Input: nums1 = [2,1,3], nums2 = [..
[LeetCode] 2429. Minimize XOR (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명Given two positive integers num1 and num2, find the positive integer x such that:x has the same number of set bits as num2, andThe value x XOR num1 is minimal.Note that XOR is the bitwise XOR operation. Return the integer x. The test cases are generated such that x is uniquely determined. The number of set bits of an integer is the number of 1's in its binary representation. 문제 ..
[LeetCode] 2657. Find the Prefix Common Array of Two Arrays (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given two 0-indexed integer permutations A and B of length n. A prefix common array of A and B is an array C such that C[i] is equal to the count of numbers that are present at or before the index i in both A and B. Return the prefix common array of A and B. A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once. 문제 예제Exampl..
[LeetCode] 3223. Minimum Length of String After Operations (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a string s.You can perform the following process on s any number of times:Choose an index i in the string such that there is at least one character to the left of index i that is equal to s[i], and at least one character to the right that is also equal to s[i].Delete the closest character to the left of index i that is equal to s[i].Delete the closest character to ..
[LeetCode] 1400. Construct K Palindrome Strings (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명Given a string s and an integer k, return true if you can use all the characters in s to construct k palindrome strings or false otherwise. 문제 예제Example 1:Input: s = "annabelle", k = 2Output: trueExplanation: You can construct two palindromes using all characters in s.Some possible constructions "anna" + "elble", "anbna" + "elle", "anellena" + "b"Example 2:Input: s = "leetcode",..
[LeetCode] 916. Word Subsets (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given two string arrays words1 and words2.A string b is a subset of string a if every letter in b occurs in a including multiplicity.For example, "wrr" is a subset of "warrior" but is not a subset of "world".A string a from words1 is universal if for every string b in words2, b is a subset of a.Return an array of all the universal strings in words1. You may return the an..