# 1. 字符串判定-最后一个有效字符
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on('line', (stringS) => {
rl.on('line', (stringL) => {
let indexS = 0;
let indexL = 0;
while(indexS < stringS.length && indexL < stringL.length) {
if (stringS.charAt(indexS) === stringL.charAt(indexL)) {
indexS++;
}
indexL++;
}
if (indexS === stringS.length) {
console.log(indexL - 1);
} else {
console.log(-1);
}
rl.close();
})
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25