Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Ruby/count_consective_numbers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Name: Shoaib Sabir
# Username: Shoaib019
# Approach: make hash count as value and number as key then find max value return its key
def count_consective_numbers(arr)
hash_one = {}
arr.each do |val|
hash_one[val] = arr.count(val)
end
hash_one.max_by {|k,v| v}.first
end
11 changes: 11 additions & 0 deletions Ruby/jump_tiles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Name: Shoaib Sabir
# Username: Shoaib019
# 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
end
pointer >= arr.length - 1 ? true : false
end