度小满 java工程师笔试,菜鸟第一题求解答

如题,我感觉自己思路是对的,给出的测试用例也过了,但是提交就是0case,请大佬帮忙看看指点一下,感激不尽!!!

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class Test1 {     public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         int n = sc.nextInt();         int[][] arr = new int[n][2];                  for(int i=0;i<n;i++){             for(int j=0;j<2;j++){                 arr[i][j] = sc.nextInt();             }                     }         Map<Integer,Integer> map = new HashMap<Integer,Integer>();                  for(int i=0;i<n;i++){             for(int j=arr[i][0];j<arr[i][1];j++){                 if (map.containsKey(j)) {                     int v = map.get(j);                     map.put(j, v + 1);                                    } else {                                         map.put(j, 1);                 }             }                     }         Iterator<Integer> it = map.keySet().iterator();         int max = Integer.MIN_VALUE;         while (it.hasNext()) {             Integer integer = it.next();             if (map.get(integer).intValue() > max) {                 max = map.get(integer).intValue();             }         }         System.out.println(max);     }
}
全部评论
public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); int q; int z; TreeMap<Integer,Integer> map=new TreeMap<Integer,Integer>(); for(int i=0;i<n;i++) { q =in.nextInt(); z=in.nextInt(); for(int j=q;j<z;j++) { if(map.get(j)==null) map.put(j,1); else { int value=map.get(j).intValue(); value++; map.put(j,value); } } } Collection<Integer> c=map.values(); int x=Collections.max(c); System.out.println(x); / }}
点赞 回复 分享
发布于 2019-09-15 12:12
没收到笔试是啥情况
点赞 回复 分享
发布于 2018-09-13 20:44
没收到笔试
点赞 回复 分享
发布于 2018-09-13 19:23
点赞 回复 分享
发布于 2018-09-13 19:07
点赞 回复 分享
发布于 2018-09-13 19:07

相关推荐

评论
点赞
3
分享

创作者周榜

更多
牛客网
牛客企业服务