Skip to content

Commit 412f911

Browse files
authored
Merge pull request #470 from fartem/1370_Increasing_Decreasing_String-update
2024-01-25 v. 4.1.3: updated "1370. Increasing Decreasing String"
2 parents 75a3a49 + 4001bb6 commit 412f911

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

leetcode-ruby.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'English'
55
::Gem::Specification.new do |s|
66
s.required_ruby_version = '>= 3.0'
77
s.name = 'leetcode-ruby'
8-
s.version = '4.1.2'
8+
s.version = '4.1.3'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[bin/leetcode-ruby README.md LICENSE]
1111
s.executable = 'leetcode-ruby'

lib/easy/1370_increasing_decreasing_string.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
def sort_string(s)
77
freq = ::Array.new(128, 0)
88
max = 0
9-
(0...s.length).each do |i|
10-
c = s[i].ord
11-
freq[c] += 1
12-
count = freq[c]
9+
s.each_byte do |b|
10+
freq[b] += 1
11+
count = freq[b]
1312

1413
max = count if count > max
1514
end

0 commit comments

Comments
 (0)