java.lang.Object
g1801_1900.s1897_redistribute_characters_to_make_all_strings_equal.Solution

public class Solution extends Object
1897 - Redistribute Characters to Make All Strings Equal.<p>Easy</p> <p>You are given an array of strings <code>words</code> ( <strong>0-indexed</strong> ).</p> <p>In one operation, pick two <strong>distinct</strong> indices <code>i</code> and <code>j</code>, where <code>words[i]</code> is a non-empty string, and move <strong>any</strong> character from <code>words[i]</code> to <strong>any</strong> position in <code>words[j]</code>.</p> <p>Return <code>true</code> <em>if you can make <strong>every</strong> string in</em> <code>words</code> <em><strong>equal</strong> using <strong>any</strong> number of operations</em>, <em>and</em> <code>false</code> <em>otherwise</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> words = [&ldquo;abc&rdquo;,&ldquo;aabc&rdquo;,&ldquo;bc&rdquo;]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> Move the first &lsquo;a&rsquo; in <code>words[1] to the front of words[2], to make</code> <code>words[1]</code> = &ldquo;abc&rdquo; and words[2] = &ldquo;abc&rdquo;.</p> <p>All the strings are now equal to &ldquo;abc&rdquo;, so return <code>true</code>.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> words = [&ldquo;ab&rdquo;,&ldquo;a&rdquo;]</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> It is impossible to make all the strings equal using the operation.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= words.length <= 100</code></li> <li><code>1 <= words[i].length <= 100</code></li> <li><code>words[i]</code> consists of lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • makeEqual

      public boolean makeEqual(String[] words)