{"id":3089,"date":"2022-04-27T23:27:59","date_gmt":"2022-04-27T15:27:59","guid":{"rendered":"https:\/\/www.zeroheart.xyz\/wordpress\/?p=3089"},"modified":"2022-04-27T23:27:59","modified_gmt":"2022-04-27T15:27:59","slug":"%e7%ae%97%e6%b3%95%e5%9f%ba%e7%a1%80%e7%ac%ac16%e5%a4%a9","status":"publish","type":"post","link":"https:\/\/www.zeroheart.xyz\/wordpress\/?p=3089","title":{"rendered":"\u7b97\u6cd5\u57fa\u7840\u7b2c16\u5929"},"content":{"rendered":"\n<p><a href=\"https:\/\/leetcode-cn.com\/problems\/number-of-longest-increasing-subsequence\/\">673. \u6700\u957f\u9012\u589e\u5b50\u5e8f\u5217\u7684\u4e2a\u6570<\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><br><em>\/**<br><\/em><em> 673. \u6700\u957f\u9012\u589e\u5b50\u5e8f\u5217\u7684\u4e2a\u6570<br><\/em><em> \u7ed9\u5b9a\u4e00\u4e2a\u672a\u6392\u5e8f\u7684\u6574\u6570\u6570\u7ec4 nums \uff0c \u8fd4\u56de\u6700\u957f\u9012\u589e\u5b50\u5e8f\u5217\u7684\u4e2a\u6570 \u3002<br><\/em><em><br><\/em><em> \u6ce8\u610f \u8fd9\u4e2a\u6570\u5217\u5fc5\u987b\u662f \u4e25\u683c \u9012\u589e\u7684\u3002<br><\/em><em><br><\/em><em><br><\/em><em><br><\/em><em> \u793a\u4f8b 1:<br><\/em><em><br><\/em><em> \u8f93\u5165: [1,3,5,4,7]<br><\/em><em> \u8f93\u51fa: 2<br><\/em><em> \u89e3\u91ca: \u6709\u4e24\u4e2a\u6700\u957f\u9012\u589e\u5b50\u5e8f\u5217\uff0c\u5206\u522b\u662f [1, 3, 4, 7] \u548c[1, 3, 5, 7]\u3002<br><\/em><em> \u793a\u4f8b 2:<br><\/em><em><br><\/em><em> \u8f93\u5165: [2,2,2,2,2]<br><\/em><em> \u8f93\u51fa: 5<br><\/em><em> \u89e3\u91ca: \u6700\u957f\u9012\u589e\u5b50\u5e8f\u5217\u7684\u957f\u5ea6\u662f1\uff0c\u5e76\u4e14\u5b58\u57285\u4e2a\u5b50\u5e8f\u5217\u7684\u957f\u5ea6\u4e3a1\uff0c\u56e0\u6b64\u8f93\u51fa5\u3002<br><\/em><em><br><\/em><em><br><\/em><em> \u63d0\u793a:<br><\/em><em><br><\/em><em> 1 &lt;= nums.length &lt;= 2000<br><\/em><em> -10^6 &lt;= nums[i] &lt;= 10^6<br><\/em><em><br><\/em><em> * <\/em><strong><em>@author <\/em><\/strong><em>zeroheart<br><\/em><em> *<br><\/em><em> *\/<br><\/em>public class Question673 {<br>    public static int findNumberOfLIS(int[] nums) {<br>        int res = 0;<br>        int max = 0;<br>        int len = nums.length;<br><br>        int[] dp = new int[len];<br>        int[] count = new int[len];<br><br>        Arrays.<em>fill<\/em>(dp, 1);<br>        Arrays.<em>fill<\/em>(count, 1);<br><br>        for(int i = 0; i&lt;len; i++){<br>            for(int j = 0; j&lt;i; j++){<br>                if(nums[i] &gt; nums[j]){<br>                    if(dp[j] + 1 == dp[i]){<br>                        count[i] += count[j];<br>                    }else if(dp[j] + 1 &gt; dp[i]){<br>                        count[i] = count[j];<br>                        dp[i] = dp[j] + 1;<br>                    }<br>                }<br>            }<br>            max = Math.<em>max<\/em>(dp[i], max);<br>        }<br><br>        for (int i = 0; i &lt; count.length; i++) {<br>            if(dp[i] == max){<br>                res += count[i];<br>            }<br>        }<br><br>        return res;<br>    }<br><br>    public static void main(String[] args) {<br>        System.<em>out<\/em>.println(<em>findNumberOfLIS<\/em>(new int[]{1,3,5,4,7}));<br>    }<br><br><br><br><br>}<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>673. \u6700\u957f\u9012\u589e\u5b50\u5e8f\u5217\u7684\u4e2a\u6570 \/** 673. \u6700\u957f\u9012\u589e\u5b50\u5e8f\u5217\u7684\u4e2a\u6570 \u7ed9\u5b9a\u4e00\u4e2a\u672a\u6392\u5e8f\u7684\u6574\u6570\u6570\u7ec4 nums \uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[155],"tags":[158],"_links":{"self":[{"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3089"}],"collection":[{"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3089"}],"version-history":[{"count":2,"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3089\/revisions"}],"predecessor-version":[{"id":3091,"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3089\/revisions\/3091"}],"wp:attachment":[{"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zeroheart.xyz\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}