Commit 40cc566

mo khan <mo.khan@gmail.com>
2020-10-20 19:23:57
Complete jump to end problem
1 parent 8490914
Changed files (1)
2020
10
2020/10/20/main.rb
@@ -0,0 +1,18 @@
+require 'minitest'
+require 'minitest/autorun'
+
+class Solution
+  def self.run(items, jumps = 0)
+    return jumps if items.nil? || items.empty?
+
+    run(items[items[1..items[0]].max..-1], jumps+1)
+  end
+end
+
+
+class SolutionTest < MiniTest::Test
+  def test_simple_example
+    # 3 -> 5 -> 4
+    assert_equal Solution.run([3, 2, 5, 1, 1, 9, 3, 4]), 2
+  end
+end