Skip to content

Commit c7af3c1

Browse files
authored
Create passing_cars.rb
1 parent 4df3a63 commit c7af3c1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

passing_cars.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def solution(a)
2+
counter = 0
3+
zero_counter = 0
4+
5+
a.each_with_index do |element, index|
6+
if element == 0
7+
zero_counter += 1
8+
else
9+
counter += zero_counter
10+
return -1 if counter == 1000000000
11+
end
12+
end
13+
counter
14+
end

0 commit comments

Comments
 (0)