Skip to content

Commit 570a5ae

Browse files
committed
2024-11-27 v. 7.1.2: added "451. Sort Characters By Frequency"
1 parent fce65b9 commit 570a5ae

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/medium/451_sort_characters_by_frequency.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# https://leetcode.com/problems/sort-characters-by-frequency/
44
# @param {String} s
55
# @return {String}
6-
def frequency_sort(s)
6+
def frequency_sort451(s)
77
arr = s.split('').sort
88
h = ::Hash.new { |v, k| v[k] = '' }
99
p1 = 0

test/medium/test_451_sort_characters_by_frequency.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class SortCharactersByFrequencyTest < ::Minitest::Test
88
def test_default_one
99
assert_equal(
1010
'eert',
11-
frequency_sort(
11+
frequency_sort451(
1212
'tree'
1313
)
1414
)
@@ -17,7 +17,7 @@ def test_default_one
1717
def test_default_two
1818
assert_equal(
1919
'aaaccc',
20-
frequency_sort(
20+
frequency_sort451(
2121
'cccaaa'
2222
)
2323
)
@@ -26,7 +26,7 @@ def test_default_two
2626
def test_default_three
2727
assert_equal(
2828
'bbAa',
29-
frequency_sort(
29+
frequency_sort451(
3030
'bbAa'
3131
)
3232
)

0 commit comments

Comments
 (0)