Practice Make Number of Distinct Characters Equal
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given two 0-indexed strings word1 and word2. A move consists of choosing two indices i and j such that 0 <= i < word1.length and 0 <= j < word2.length and swapping word1[i] with word2[j]. Return true if it is possible to get the number of distinct characters in word1 and word2 to be equal with exactly one move. Return false otherwise.
Source: Make Number of Distinct Characters Equal on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
word1 = "ac", word2 = "b"
false
# Example 2
word1 = "abcc", word2 = "aab"
true
# Example 3
word1 = "abcde", word2 = "fghij"
true
Constraints
Related LeetCode Problems
Practice more problems similar to Make Number of Distinct Characters Equal.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.