Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = ['peshoishere', '3', 'eho', 'piere', 'telerik'];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let title = gets().split('');
- const values = Number(gets());
- let isFound, output;
- for (let i = 0; i < values; i++) {
- const word = gets().toString();
- output = title;
- let limiter = 0;
- for (const letter of word) {
- if (output.indexOf(letter, limiter) > -1) {
- limiter = output.indexOf(letter, limiter);
- output.splice(limiter, 1);
- isFound = true;
- } else {
- isFound = false;
- break;
- }
- }
- if (isFound) {
- title = output;
- print(output.join(''));
- } else {
- print('No such title found!');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement