奇安信816笔试(本菜醉了)

第一题
题目描述有点迷,反复调试都是0,一看AC竟然是三步问题??!
原提交代码(通过0
public static int CalulateMethodCount (int num_money) {
    int dp[]  = new int[num_money+1];
    if(num_money<=0) return 0;
    dp[0]=0;
    dp[1]=1;
    for (int i = 1; i <num_money; i++) {
        int k = 0,count=0;
        while(count<=i){
            k+=dp[count];
            count++;
        }
        dp[i+1]=k+1;
    }

    return dp[num_money];
//甚至可以直接一行:
 //return 1<<(num_money-1);
}
第二题
啊,用例考虑有问题,这是我提交的,只有0.4┭┮﹏┭┮
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        s=s.replaceAll("\\t"," ");
        //s=s.replaceAll("\\s{1,}"," ");
        String  [] strings = s.split(" ");
        Stack<String> stack = new Stack<>();
        Stack<String> undo = new Stack<>();
        for(String string :strings){
            if(string.equals("undo") && !stack.empty()){
                undo.push(stack.pop());
            } else if (string.equals("redo") && !undo.empty()) {
                stack.push(undo.pop());
            }
            else{
                stack.push(string);
            }
        }
        Stack<String> res = new Stack<>();
        while(!stack.empty()){
            res.push(stack.pop());
        }
        StringBuffer sb = new StringBuffer();
        while (!res.empty()){
            sb.append(res.pop()+" ");
        }
        String resString  = sb.toString();
        System.out.println(resString.trim());
    }
}



#奇安信笔试##笔试题目##奇安信#
全部评论
第二题是ac代码吗
点赞 回复
分享
发布于 2020-08-16 17:24
大佬通过多少?
点赞 回复
分享
发布于 2020-08-16 17:27
阅文集团
校招火热招聘中
官网直投
大佬是java服务端吗?有选择题吗?
点赞 回复
分享
发布于 2020-09-01 18:39

相关推荐

3 4 评论
分享
牛客网
牛客企业服务