Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.






                function lengthOfLIS(nums) {
  let len = nums.length,
    max = 1,
    dp = [];
  dp[0] = [1];			//初始化dp[0][0]的值
  for (let i = 1; i < len; i++) {
    dp[i] = [];
	dp[i][i] = 1;		//初始化dp[i][i]的值
    for (let j = 0; j < i; j++) {	//让第i个元素与前j个元素逐一比较
      dp[i][j] = dp[i-1][j];		//默认沿用上一行的值
      if (nums[i] > nums[j]) {		//当第i个元素比第j个元素大时,取其中的较大值
        dp[i][i] = Math.max(dp[i][i], dp[i][j] + 1);
	max = Math.max(max, dp[i][i]);
  return max;

let nums = [10,9,2,5,3,7,101,18];
console.log("[10,9,2,5,3,7,101,18]", lengthOfLIS(nums));

nums = [0];
console.log("[0]", lengthOfLIS(nums));

nums = [4,10,4,3,8,9];
console.log("[4,10,4,3,8,9]", lengthOfLIS(nums));