Commit 1b999e4
Changed files (1)
2020
08
11
2020/08/11/main.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+def assert_equal(x, y)
+ raise [x, y].inspect unless x == y
+end
+
+class Solution
+ def self.run(string)
+ max = 0
+ current = 0
+
+ 0.upto(string.chars.size) do |i|
+ if string[i] == string[i-1]
+ max = max > current ? max : current
+ current = 0
+ end
+ current = current + 1
+ end
+
+ max
+ end
+end
+
+assert_equal Solution.run('abrkaabcdefghijjxxx'), 10
+
+# step 1. understand the problem
+# step 2. pick a solution
+# step 3. write the solution