9.15小米笔试

希望第一道ac的大佬帮忙解释一下,我在leetcode上提交是能通过的

#笔试题目##小米#
全部评论
判断空字符串输入用while(sc.hasNextLine()) ,而不是sc.hasNext()就过了
1 回复 分享
发布于 2020-09-15 21:07
有大佬可以帮我看一下代码吗 第二题 public class dechar {     public static void main(String[] args) {         Scanner sc=new Scanner(System.in);         String st=sc.nextLine();         HashSet<Character> hash=new HashSet<>();         int i=0;         ArrayList arr=new ArrayList();         while (i<st.length()){             char c=st.charAt(i);             if(!hash.contains(c)||c==' &(5528)#39;){                 hash.add(c);                 arr.add(c);                 i++;             }else{                 i++;             }         }         for(Object ch:arr){             System.out.print(ch);         }     } }
点赞 回复 分享
发布于 2020-09-16 09:23
有大佬可以帮我看一下代码吗 第一题AC 80%
点赞 回复 分享
发布于 2020-09-16 09:22
我不懂为啥第一题输入有问题,后来我用了sys.stdin.readlines()才成功的,耽误了好长时间
点赞 回复 分享
发布于 2020-09-15 20:47
可以看看这个帖子:https://www.nowcoder.com/discuss/511789
点赞 回复 分享
发布于 2020-09-15 20:47
我第一题输入没整好,就对了第二题
点赞 回复 分享
发布于 2020-09-15 20:45
cpp?
点赞 回复 分享
发布于 2020-09-15 20:45

相关推荐

求offer的大角牛:不吃香菜
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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