Skip to content

Commit 0f43888

Browse files
committed
Create README - LeetHub
1 parent 2f496c6 commit 0f43888

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/sort-characters-by-frequency/">451. Sort Characters By Frequency</a></h2><h3>Medium</h3><hr><div><p>Given a string <code>s</code>, sort it in <strong>decreasing order</strong> based on the <strong>frequency</strong> of the characters. The <strong>frequency</strong> of a character is the number of times it appears in the string.</p>
2+
3+
<p>Return <em>the sorted string</em>. If there are multiple answers, return <em>any of them</em>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre><strong>Input:</strong> s = "tree"
9+
<strong>Output:</strong> "eert"
10+
<strong>Explanation:</strong> 'e' appears twice while 'r' and 't' both appear once.
11+
So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer.
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre><strong>Input:</strong> s = "cccaaa"
17+
<strong>Output:</strong> "aaaccc"
18+
<strong>Explanation:</strong> Both 'c' and 'a' appear three times, so both "cccaaa" and "aaaccc" are valid answers.
19+
Note that "cacaca" is incorrect, as the same characters must be together.
20+
</pre>
21+
22+
<p><strong class="example">Example 3:</strong></p>
23+
24+
<pre><strong>Input:</strong> s = "Aabb"
25+
<strong>Output:</strong> "bbAa"
26+
<strong>Explanation:</strong> "bbaA" is also a valid answer, but "Aabb" is incorrect.
27+
Note that 'A' and 'a' are treated as two different characters.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>1 &lt;= s.length &lt;= 5 * 10<sup>5</sup></code></li>
35+
<li><code>s</code> consists of uppercase and lowercase English letters and digits.</li>
36+
</ul>
37+
</div>

0 commit comments

Comments
 (0)