This action will force synchronization from wangjili/Algorithm, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
package nowCoderClass1.section12;/*** 求最长递增子序列* Created by Dell on 2017年06月04日.*/public class LongestIncreasingSubsequence {/*** 大问题分成小问题,如果求以i结尾的最长序列,找到前一个比其小的值的最长序列值,在其基础上+1* 利用了子问题的解求解大问题* @param A* @param n* @return*/public int getLIS(int[] A, int n) {if(n==1) {return n;}int[] dp=new int[n];dp[0]=1;int max=1;for(int i=1;i<n;i++){dp[i]=findMax(A,i,dp)+1;max=dp[i]>max?dp[i]:max;}//// for(int i=0;i<n;i++){// System.out.print(dp[i]+" ");// }return max;}/*** 求dp[i]时,在dp[0...n-1]中存在比A[i]小的数,从这些数中选出最大的*/public int findMax(int[] A,int n,int[] dp){int max=0;for(int i=n-1;i>=0;i--){if(A[i]<A[n])max=dp[i]>max?dp[i]:max;}return max;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。