this entry collects the solution files i have for special array i. i may expand it with a fuller write-up later, but the implementation files are already here.
available solution files
- Scala
special-array-i/solution.scala
notes and solution files for special array i.
this entry collects the solution files i have for special array i. i may expand it with a fuller write-up later, but the implementation files are already here.
special-array-i/solution.scalaobject Solution {
def isArraySpecial(nums: Array[Int]): Boolean = {
if (nums.length <= 1) {
true
} else {
var ok = true
var i = 1
while (i < nums.length && ok) {
if ((nums(i) & 1) == (nums(i - 1) & 1)) {
ok = false
}
i += 1
}
ok
}
}
}