第一题 public static String getRes(String s){ String[] strs = s.split(" "); if (strs[0].equals(strs[1])) return "Yes"; int preIndex=0; int nextIndex=0; int count=0; for (int i=0; i<strs[0].length(); i++){ if (strs[0].charAt(i)==strs[1].charAt(i)) continue; if (strs[0].charAt(i)!=strs[1].charAt(i)&;&;count==0){ preIndex=i; count++; }else if (strs[0].charAt(i)!=strs[1].charAt(i)&;&;count==1){ count++; nextIndex=i; boolean isRes = strs[0].charAt(preIndex)==strs[1].charAt(nextIndex) &;&; strs[0].charAt(nextIndex)==strs[1].charAt(preIndex); if(!isRes) return "No"; }else{ return "No"; } } if (count<2) return "No"; return "Yes"; } }
点赞 评论

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-15 17:46
暑期就挂了,秋招还有机会吗
大聪明777:研发提前批,14号刚开的,官网上面的配图上有写。提前批没过的话,秋招还可以投,不过前面的笔试/面试记录会被保留,供秋招参考
26届校招投递进展
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务