题解 | #Redraiment的走法#

Redraiment的走法

https://www.nowcoder.com/practice/24e6243b9f0446b081b1d6d32f2aa3aa

#include <stdio.h>
int _MaxStep = 0;
void step(int v, int index,int stepCount, int* arr, int max)
{
    if(index >= max)
    {
        if(_MaxStep < stepCount)
            _MaxStep = stepCount;
        return;
    }
    else if(index < max){
        if(arr[index] > v){
            step(v,index+1,stepCount,arr,max);
            step(arr[index],index+1,stepCount+1,arr,max);
        }else {
            step(v,index+1,stepCount,arr,max);
        }
    }
}


int main() {
    int n = 0;
    int arr[200] = {0};

    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&arr[i]);
    }
    
    for(int i = 0; i < n; i++)
    {
        step(arr[i], i+1,1, arr, n);
    }
    printf("%d",_MaxStep);
    return 0;
}

全部评论

相关推荐

八股刚起步,看了javaguide,小林coding,还有面渣,感觉面渣是体验最好的,请问只看面渣够用吗,有不完善的需要补吗?
码农索隆:先背最基础的知识,然后理解情景题,现在面试大多数喜欢问情景题,更考验面试者的基础和临场发挥情况
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务