Skip to content

Commit adbee2c

Browse files
committed
Add more problems
1 parent 08f7654 commit adbee2c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
arr = [1, 4, 5, 6, 5, 2, 3, 3, 2, 1]
2+
3+
num_count = {}
4+
arr.each do |num|
5+
if(num_count[num])
6+
num_count[num] = num_count[num] + 1
7+
else
8+
num_count[num] = 1
9+
end
10+
end
11+
12+
num_count.each do |num, count|
13+
if(count == 1)
14+
p num
15+
break
16+
end
17+
end

Problems/second_max_value.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arr = [1, 4, 5, 8, 6, 2, 3, 3, 2, 1]
2+
3+
first = 0
4+
second = 0
5+
arr.each do |num|
6+
if(num > first)
7+
second = first
8+
first = num
9+
elsif(num < first && num > second)
10+
second = num
11+
end
12+
end
13+
p second

0 commit comments

Comments
 (0)