java.lang.Object
g2401_2500.s2423_remove_letter_to_equalize_frequency.Solution

public class Solution extends Object
2423 - Remove Letter To Equalize Frequency.<p>Easy</p> <p>You are given a <strong>0-indexed</strong> string <code>word</code>, consisting of lowercase English letters. You need to select <strong>one</strong> index and <strong>remove</strong> the letter at that index from <code>word</code> so that the <strong>frequency</strong> of every letter present in <code>word</code> is equal.</p> <p>Return <code>true</code> <em>if it is possible to remove one letter so that the frequency of all letters in</em> <code>word</code> <em>are equal, and</em> <code>false</code> <em>otherwise</em>.</p> <p><strong>Note:</strong></p> <ul> <li>The <strong>frequency</strong> of a letter <code>x</code> is the number of times it occurs in the string.</li> <li>You <strong>must</strong> remove exactly one letter and cannot chose to do nothing.</li> </ul> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> word = &ldquo;abcc&rdquo;</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> Select index 3 and delete it: word becomes &ldquo;abc&rdquo; and each character has a frequency of 1.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> word = &ldquo;aazz&rdquo;</p> <p><strong>Output:</strong> false</p> <p><strong>Explanation:</strong> We must delete a character, so either the frequency of &ldquo;a&rdquo; is 1 and the frequency of &ldquo;z&rdquo; is 2, or vice versa. It is impossible to make all present letters have equal frequency.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>2 <= word.length <= 100</code></li> <li><code>word</code> consists of lowercase English letters only.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • equalFrequency

      public boolean equalFrequency(String word)