标签:img 解答 alt target int res pre solution span
public class Solution { public int RectCover(int target) { if(target<=0){ return 0; } if(target==1 || target==2){ return target; } int res=2; int pre=1; int tmp=0; for(int i=3;i<=target;i++){ tmp=res; res=res+pre; pre=tmp; } return res; } }
public class Solution { public int RectCover(int target) { if(target<=0){ return 0; } if(target==1 || target==2){ return target; } return RectCover(target-1)+RectCover(target-2); } }
动态规划
标签:img 解答 alt target int res pre solution span
原文地址:https://www.cnblogs.com/chanaichao/p/10120511.html