Skip to content

Commit d3c07db

Browse files
committed
Add 3133. Minimum Array End
1 parent ebcaf13 commit d3c07db

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package sierikov.leetcode.tasks.medium
2+
3+
object MinimumArrayEnd {
4+
def minEnd(n: Int, x: Int): Long = {
5+
var result: Long = x
6+
var count = n - 1
7+
while (count > 0) {
8+
result = (result + 1) | x
9+
count -= 1
10+
}
11+
result
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package sierikov.leetcode.tasks.medium
2+
3+
import org.scalatest.flatspec.AnyFlatSpec
4+
import org.scalatest.matchers.should.Matchers
5+
6+
class MinimumArrayEndTest extends AnyFlatSpec with Matchers {
7+
import MinimumArrayEnd._
8+
9+
it should "pass basic tests" in {
10+
minEnd(3, 4) shouldBe 6
11+
minEnd(2, 7) shouldBe 15
12+
}
13+
}

0 commit comments

Comments
 (0)