京东笔试4.16

编程题1:只过了90%
//public class Main{
//    public static void main(String[] args){
//        Scanner sc = new Scanner(System.in);
//        int T = Integer.parseInt(sc.nextLine().trim());
//        while(T-- > 0){
//            int n = Integer.parseInt(sc.nextLine().trim());
//            Stack<String> s = new Stack<>();
//            for(int i = 0; i < n; i++){
//                s.push(sc.nextLine().trim());
//            }
//            if(isOk(s)){
//                System.out.println("Yes");
//            }else {
//                System.out.println("No");
//            }
//
//        }
//    }
//
//    public static boolean isOk(Stack<String> s){
//        Stack<String> rs = new Stack<>();
//        while (!s.isEmpty()){
//            String temp1 = s.pop();
//            if(!temp1.contains("end")){
//                if(rs.isEmpty()) return false;
//                String temp2 = rs.pop();
//                if(temp2.contains(temp1)) continue;
//                return false;
//            }
//            if(temp1.contains(s.peek()) && !s.peek().contains("end")){
//                s.pop();
//                continue;
//            }
//            rs.push(temp1);
//        }
//
//        return true;
//    }
//}
2:只过了18%,为啥呀,希望指点一二。
public class Main {
    static int max = 0;
    static List<Integer> combine = new LinkedList<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while (T-- > 0) {
            int n = sc.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = sc.nextInt();
            }
            max = 0;
            isMax(nums);
            System.out.println(max);
        }
    }

    public static void isMax(int[] nums){
        int n = nums.length;
        for(int i = 0; i < n; i++){
            int l = i;
            int r = n-i-1;
            if(l/2 > r) break;
            if(r/2 > l || l/2 > r) continue;
            max = Math.max(max, nums[i]);
        }
    }
}



#京东实习##笔经##笔试时间#
全部评论
第一题去一下空格就100了
3 回复 分享
发布于 2022-04-16 21:02
第二题永远18%,不知为何呀
2 回复 分享
发布于 2022-04-16 21:08
第二题百分之18😂
2 回复 分享
发布于 2022-04-16 21:28
第二题,找中位数,大家有什么好的方法吗?只通过了30%...
1 回复 分享
发布于 2022-04-16 21:13
第一题不是红蓝球数字和吗??
1 回复 分享
发布于 2022-04-16 21:52
1的是因为最后的话,要判断栈是否为空,第二个我也不知道😅
点赞 回复 分享
发布于 2022-04-16 21:03
发现有空格,但是忘了API了
点赞 回复 分享
发布于 2022-04-16 21:07
#include<iostream> #include<stack> using namespace std; int t; int main(){     cin>>t;     while(t--){         int n = 0;         cin>>n;         stack<string> st; getchar();         while(n--){             string s;             getline(cin,s);             if(!((s[0]=='e&(665)#39;)&&(s[1]=='n&(392)#39;)&&(s[2]=='d&(406)#39;)&&s[3]==' &#39;)){                 st.push(s);             }else{                 string tail = s.substr(4);                 if(tail==st.top()){                     st.pop();                 }             }         }         if(st.size()==0){             cout<<"Yes"<<endl;         }else{             cout<<"No"<<endl;         }     }     return 0; } 谁能帮忙看看第一题,为啥一直0%😭😭😭,本地都可以过,放到上面连测试都过不了
点赞 回复 分享
发布于 2022-04-16 21:08
😥我用C++写 输入怎么都搞不对 真的麻了
点赞 回复 分享
发布于 2022-04-16 21:09
***题
点赞 回复 分享
发布于 2022-04-16 21:10
def judge(a):     astr = str(a)     if len(astr) == 1:         print(a)         return 0     d = int(astr[0]) - int(astr[1])     for m in range(len(astr)-1):         if int(astr[m]) - int(astr[m+1]) != d:             return 1     print(a)     return 0 T = int(input()) xarr = [] res = [] for i in range(T):     xarr.append(int(input())) for i in range(T):     if xarr[i] > 9876543210:         num = str(xarr[i])         flag = 0         for j in num:             if int(j) > int(num[0]):                 flag = 1                 break             if int(j) < int(num[0]):                 break         if flag == 1:             if num[0] == 9:                 print('1'*(len(num)+1))             else:                 ans = str(int(num[0])+1)                 print(ans*len(num))         else:             print(num[0]*len(num))     else:         itr = xarr[i]         while judge(itr):             itr += 1
点赞 回复 分享
发布于 2022-04-16 21:11
第一题循环内和最后的返回都要判断栈空
点赞 回复 分享
发布于 2022-04-16 21:29
有个问题,写的程序如果有些案例通过,有些案例超时,系统会不会报超时
点赞 回复 分享
发布于 2022-04-16 21:30
第一题ac第二题27
点赞 回复 分享
发布于 2022-04-16 21:45
C加加调试一个小时第一题 本地死活都是对的 提交死活都是9分
点赞 回复 分享
发布于 2022-04-16 22:49
有大佬知道京东考试断网了去哪里联系hr啊,最后连卷子都没交直接关了浏览器😂
点赞 回复 分享
发布于 2022-04-16 23:10
有没有大佬康康为什么只过了45啊 #include <iostream> #include <stack> using namespace std; int main() { int t; int jud = 1; cin >> t; while (t--) { stack<string>s; int n; jud = 1; string temp,temp2; cin >> n; for (int i = 0; i < n; i++) { cin >> temp; if (temp != "end") { s.push(temp); } else if(temp=="end") { cin >> temp2; if (!s.empty()&&temp2 == s.top()) { s.pop(); } else { jud = 0; break; } } } if (jud == 1&&s.empty()) { cout << "Yes"<</string></stack></iostream>
点赞 回复 分享
发布于 2022-04-16 23:28
这是实习吗??
点赞 回复 分享
发布于 2022-04-17 13:15
收到面试消息了吗
点赞 回复 分享
发布于 2022-04-19 18:32
第一题ac,第二题27%
点赞 回复 分享
发布于 2022-04-19 20:04

相关推荐

01-14 12:08
门头沟学院 Java
神哥了不得:(非引流)1.既然发出来了简历,就稍微提一点点小建议,确实简历很不错了,练手项目可以换一些质量高的,工作内容,可以加上一些量化指标,比如第一条系统响应速度由多少变成多少,减少了百分之多少,第4条就很不错。2.广投,年前实习招募比较少了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
2
5
分享

创作者周榜

更多
牛客网
牛客企业服务