LeetCode 300. Longest Increasing Subsequence in F#
URL
leetcode.com/problems/longest-increasing-su..
Code
github.com/syohex/dotnet-study/blob/master/..
let lengthOfLis (nums: int list) : int =
let numsA = nums |> Array.ofList
let dp = Array.init numsA.Length (fun _ -> 1)
let mutable ret = 1
for i in 1 .. (numsA.Length - 1) do
for j in 0 .. (i - 1) do
if numsA.[j] < numsA.[i] then
dp.[i] <- System.Math.Max(dp.[i], dp.[j] + 1)
ret <- System.Math.Max(ret, dp.[i])
ret