public int lengthOfLIS(int[] nums) {
        if (nums == null) return 0;
        int[] dp = new int[nums.length];
        int maxLen = 0;
        for (int i = 0; i < nums.length; ++i) {
            int len = 0;
            for (int j = 0; j < i; ++j) {
                if (nums[j] < nums[i]) len = Math.max(len, dp[j]);
            }
            dp[i] = len + 1;
            maxLen = Math.max(maxLen, dp[i]);
        }
        return maxLen;
    }