We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9539862 + 228d930 commit e1bd790Copy full SHA for e1bd790
Ruby/count_consective_numbers.rb
@@ -0,0 +1,10 @@
1
+# Name: Shoaib Sabir
2
+# Username: Shoaib019
3
+# Approach: make hash count as value and number as key then find max value return its key
4
+def count_consective_numbers(arr)
5
+ hash_one = {}
6
+ arr.each do |val|
7
+ hash_one[val] = arr.count(val)
8
+ end
9
+ hash_one.max_by {|k,v| v}.first
10
+end
Ruby/jump_tiles.rb
@@ -0,0 +1,11 @@
+# Approach: in loop added only those elements on which pointer value is same
+# then compare pointer value with size of array
+def jump_tiles(arr)
+ pointer = 0
+ arr.each_with_index do |_,idx|
+ pointer = pointer + arr[idx] if pointer == idx
+ pointer >= arr.length - 1 ? true : false
11
0 commit comments