https://leetcode.com/problems/find-maximum-number-of-string-pairs/description/
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
1
2
3
4
5
6
7
8
9
10
|
class Solution:
def maximumNumberOfStringPairs(self, words: List[str]) -> int:
answer = 0
for i in range(len(words)):
for j in range(i+1, len(words)):
if sorted(words[i]) == sorted(words[j]):
answer += 1
break
return answer
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
백준 28235 코드마스터 2023 (0) | 2023.09.11 |
---|---|
leetcode 2798. Number of Employees Who Met the Target (0) | 2023.08.04 |
leetcode 2769. Find the Maximum Achievable Number (0) | 2023.07.13 |
leetcode 2739. Total Distance Traveled (0) | 2023.07.07 |
leetcode 2651. Calculate Delayed Arrival Time (0) | 2023.07.06 |
댓글