function se(s){
let i =1;
let n = s.length;
let cnt =0;
while(i<n){
if(s[i]==s[i-1]){
cnt++;
i+=2;
}else{
i++;
}
}
return cnt;
}
通过82%,为什么????
var n;
var hang =0;
function Point(l,r){
this.l =l;
this.r =r;
}
while(sc = read_line()){
hang ++;
if(hang==1){
n = parseInt(sc);
}else if(hang==2){
sl = sc.split(" ");
}else{
sr = sc.split(" ");
let ar =[];
for(let i =0;i<n;i++){
let obj = new Point(sl[i],sr[i]);
ar.push(obj);
}
ar.sort((x,y)=>{
if(x.l!=y.l){
return x.l - y.l;
}
return x.r-y.r;
});
let map = new Map();
for(let i =0;i+1<n;i++){
let obj1 = ar[i];
let obj2 = ar[i+1];
if(obj1.r>=obj2.l){
let s1 = obj1.l+'#'+obj2.l;
map.set(s1,map.get(s1)==undefined?1:1+map.get(s1));
let s2 = obj2.l+'#'+obj1.r;
map.set(s2,map.get(s2)==undefined?2:2+map.get(s2));
let s3 = obj1.l+'#'+obj2.r;
map.set(s3,map.get(s3)==undefined?1:1+map.get(s3));
}
else{
let s4 = obj1.l+'#'+obj1.r;
map.set(s4,map.get(s4)==undefined?1:1+map.get(s4));
let s5 = obj2.l+'#'+obj2.r;
map.set(s5,map.get(s5)==undefined?1:1+map.get(s5));
}
}
let maxx =0;
for(let key of map.keys()){
if(maxx<map.get(key)){
maxx=map.get(key);
}
}
let sum = 0;
for(let key of map.keys()){
if(map.get(key)==maxx){
let sp = key.split('#');
sum+=(parseInt(sp[1])-parseInt(sp[0]));
}
}
let res = maxx+" "+sum;
print(res);
}
}
第二题超时????
#做完美团2023秋招笔试,你还好吗##你觉得今年春招回暖了吗##23届找工作求助阵地##互联网没坑了,还能去哪里?##我的实习求职记录#