Shohei Yoshida
Shohei Yoshida's Blog

Shohei Yoshida's Blog

LeetCode 334. Increasing Triplet Subsequence in F#

Shohei Yoshida's photo
Shohei Yoshida
·Oct 11, 2022·

1 min read

URL

leetcode.com/problems/increasing-triplet-su..

Code

github.com/syohex/dotnet-study/blob/master/..

let increasingTriplet (nums: int list) : bool =
    let rec increasingTriplet' nums first second =
        match nums with
        | [] -> false
        | h :: t ->
            if h <= first then
                increasingTriplet' t h second
            elif h <= second then
                increasingTriplet' t first h
            else
                true

    increasingTriplet' nums System.Int32.MaxValue System.Int32.MaxValue
 
Share this