본문 바로가기

IT

(117)
[Leetcode] 1748. Sum of Unique Elements https://leetcode.com/problems/sum-of-unique-elements class Solution: def sumOfUnique(self, nums: List[int]) -> int: unique = [] for i in nums[:]: if nums.count(i) == 1: unique.append(i) sum = 0 for i in unique: sum += i return sum
[Leetcode] 2405. Optimal Partition of String class Solution: def partitionString(self, s: str) -> int: substrings = [] sub = '' for n in s: if n in sub: substrings.append(sub) sub = n else: sub += n substrings.append(sub) return len(substrings) https://leetcode.com/problems/optimal-partition-of-string Optimal Partition of String - LeetCode Can you solve this real interview question? Optimal Partition of String - Level up your coding skills..
[Leetcode] 2215. Find the Difference of Two Arrays https://leetcode.com/problems/find-the-difference-of-two-arrays Find the Difference of Two Arrays - LeetCode Can you solve this real interview question? Find the Difference of Two Arrays - Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where: * answer[0] is a list of all distinct integers in nums1 which are not present in nums2 leetcode.com class Solution: def..
[Leetcode] 2418. Sort the People https://leetcode.com/problems/sort-the-people Sort the People - LeetCode Can you solve this real interview question? Sort the People - You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n. For each index i, names[i] and heights[i] denote the name leetcode.com class Solution: def sortPeople(self, names: List[str], h..
[Leetcode] 1817. Finding the Users Active Minutes https://leetcode.com/problems/finding-the-users-active-minutes Finding the Users Active Minutes - LeetCode Can you solve this real interview question? Finding the Users Active Minutes - You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the leetcode.com class Solution: def f..
[Leetcode] 2657. Find the Prefix Common Array of Two Arrays https://leetcode.com/problems/find-the-prefix-common-array-of-two-arrays Find the Prefix Common Array of Two Arrays - LeetCode Can you solve this real interview question? Find the Prefix Common Array of Two Arrays - 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 class Solution: def findThe..
[Leetcode] 2744. Find Maximum Number of String Pairs https://leetcode.com/problems/find-maximum-number-of-string-pairs Find Maximum Number of String Pairs - LeetCode Can you solve this real interview question? Find Maximum Number of String Pairs - You are given a 0-indexed array words consisting of distinct strings. The string words[i] can be paired with the string words[j] if: * The string words[i] is equal to the rev leetcode.com class Solution:..
[Leetcode] 2103. Rings and Rods https://leetcode.com/problems/rings-and-rods/ Rings and Rods - LeetCode Can you solve this real interview question? Rings and Rods - There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9. You are given a string rings of length 2n that describes the n rings leetcode.com class Solution: def countPoints(self, rings: str) -> int:..

728x90