Skip to content

Commit

Permalink
1st day
Browse files Browse the repository at this point in the history
  • Loading branch information
a-abdellatif98 committed Feb 14, 2022
1 parent 2c979f0 commit bd3d949
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ImplementstrStr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def str_str(haystack, needle)
return 0 if (haystack.empty? && needle.empty?) || (haystack.empty? == false && needle.empty?)
(0..haystack.size-1).each do |i|
if haystack[i..i+needle.size-1] == needle
return i
end
end
return -1


end

puts str_str("aaaa","bba")

0 comments on commit bd3d949

Please sign in to comment.