Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Longest increasing subsequence

    Longest increasing subsequence

    Mediumdynamic programmingbinary search

    Return the length of the longest strictly increasing subsequence of nums. It needn't be contiguous but must keep the original order.

    Example 1

    Input:  nums = [10,9,2,5,3,7,101,18]
    Output: 4

    For example 2, 3, 7, 101.

    Example 2

    Input:  nums = [0,1,0,3,2,3]
    Output: 4

    Example 3

    Input:  nums = [7,7,7,7]
    Output: 1

    Constraints

    • 1 ≤ nums.length ≤ 2500
    • -10⁴ ≤ nums[i] ≤ 10⁴

    Submit checks your solution against 8 tests, including hidden ones.

    /**
     * @param {int[]} nums
     * @return {int}
     */
    function lengthOfLIS(nums) {
      
    }
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.