728x90

코딩 테스트/leetCode 46

[leetCode] 2176. Count Equal and Divisible Pairs in an Array (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/count-equal-and-divisible-pairs-in-an-array/ Count Equal and Divisible Pairs in an Array - 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 정수 배열 nums와 정수 k가 주어진다. (i , j) 로 2개씩 짝지어 만드는 조합 중 i == j 이고, i의 인덱스 j의 인덱스의 곱한 값을 k로 나누었을 때 나머지..

[leetCode] 2315. Count Asterisks (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/count-asterisks/ Count Asterisks - 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 * 또는 | 을 포함하거나, 포함하지 않는 문자열 s가 주어질 때, * 의 개수를 반환하는 문제. | (vertical bars)는 짝수 개로 존재한다. * (Asterisk) 를 셀 때 bars pair의 사이에 있는 것은 제외한다. # 첫번째 테스트 케이스만 고려 cl..

[leetCode] 1913. Maximum Product Difference Between Two Pairs (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/maximum-product-difference-between-two-pairs/ Maximum Product Difference Between Two Pairs - 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 주어진 리스트 nums에서 최대값 쌍과 최소값 쌍을 고르고 (a * b) - (c * d) 로 연산한 값을 반환하는 문제 (각 쌍을 서로 곱한 후 빼기) class So..

[leetCode] 557. Reverse Words in a String III (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/reverse-words-in-a-string-iii/ Reverse Words in a String III - 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 문자열 s가 주어진다. 공백 기준으로 나눈 문자 단위로 순서를 뒤집고 다시 공백 기준으로 합쳐서 문자열로 반환하는 문제. class Solution: def reverseWords(self, s: str) -> str: a..

[leetCode] 1773. Count Items Matching a Rule (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/count-items-matching-a-rule/ Count Items Matching a Rule - 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 3개 원소를 가지는 리스트를 1개 이상 가지는 중첩 리스트items가 주어진다. 원소는 순서대로 type, color, name을 나타낸다. ruleKey와 ruleValue가 주어졌을 때, 맞는 값이 items에 몇 개 있는 지..

[leetCode] 1528. Shuffle String (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/shuffle-string/ Shuffle String - 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 서로 길이가 같은, 문자열 s와 정수 배열 indices가 주어진다. s의 char들이 indices 값을 인덱스로 해서 재배치 된 값을 반환하는 문제. class Solution: def restoreString(self, s: str, indices: List[int]) ..

[leetCode] 2194. Cells in a Range on an Excel Sheet (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/submissions/ Cells in a Range on an Excel Sheet - 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 Input: s = "K1:L2" Output: ["K1","K2","L1","L2"] 문자열 s가 주어진다. s는 엑셀과 같이 행(row)은 1부터 n까지의 정수로 나타내고 열(co..

[leetCode] 1967. Number of Strings That Appear as Substrings in Word (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/ Number of Strings That Appear as Substrings in Word - 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 return the number of strings in patterns that exist as a substring in word. A su..

[leetCode] 2427. Number of Common Factors (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/number-of-common-factors/ Number of Common Factors - 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 주어진 정수 a, b의 공약수를 반환하는 문제. class Solution: def commonFactors(self, a: int, b: int) -> int: a_div = [] cnt = 0 for i in range(1, a + 1)..

[leetCode] 561. Array Partition (Python)

▼ 문제 바로가기 (링크) ▼ https://leetcode.com/problems/array-partition/ Array Partition - 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 짝수 개의 원소를 가지는 배열 nums가 주어진다. 2개씩 조합했을 때(combination) 각 원소 중 더 작은 값만 골라 모두 더했을 때 최대값을 구하는 문제. class Solution: def arrayPairSum(self, nums: List[int]) -> ..

728x90