![JAR search and dependency download from the Maven repository](/logo.png)
g0601_0700.s0674_longest_continuous_increasing_subsequence.Solution.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-kotlin Show documentation
Show all versions of leetcode-in-kotlin Show documentation
Kotlin-based LeetCode algorithm problem solutions, regularly updated
package g0601_0700.s0674_longest_continuous_increasing_subsequence
// #Easy #Array #2023_02_15_Time_201_ms_(84.21%)_Space_36.9_MB_(68.42%)
class Solution {
fun findLengthOfLCIS(nums: IntArray): Int {
var ans = 1
var count = 1
for (i in 0 until nums.size - 1) {
if (nums[i] < nums[i + 1]) {
count++
} else {
ans = max(count, ans)
count = 1
}
}
return max(ans, count)
}
private fun max(n1: Int, n2: Int): Int {
return Math.max(n1, n2)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy