Skip to content

Commit d9e226f

Browse files
authored
Create fish.rb
1 parent 48658e8 commit d9e226f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

fish.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def solution(a, b)
2+
deaths = 0
3+
stack = []
4+
b.each_with_index do |el, i|
5+
if b[i] == 1
6+
stack.push(i)
7+
next
8+
end
9+
10+
while stack.length > 0
11+
deaths += 1
12+
if a[i] > a[stack.last]
13+
stack.pop()
14+
else
15+
break
16+
end
17+
end
18+
end
19+
b.length - deaths
20+
end

0 commit comments

Comments
 (0)