Advertisement
Guest User

Untitled

a guest
Feb 17th, 2022
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = [
  2. 'tepeplpepreik',
  3. '3',
  4. 'telerik ',
  5. 'gagaga',
  6. 'gp'
  7.  
  8.  
  9. ];
  10.  
  11. let print = this.print || console.log;
  12. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  13. // let str = '1234567';
  14. // let index = 3;
  15. //str = str.substring(0, index) + str.substring(index + 1);
  16.  
  17.  
  18. let word= gets().split('')
  19. let n = +gets()
  20. let l = word.length
  21.  
  22. let newWord=[];
  23.  
  24. isTitle=false;
  25. for (let i = 0; i < n; i++) {
  26. let sub = gets().split('')
  27.  
  28. for (let j = 0; j < l; j++) {
  29.  
  30. let first = word.shift();
  31. newWord.push(first);
  32.  
  33. for(let d = 0; d < sub.length; d++){
  34. let start = sub[d]
  35. if(start===first){
  36. sub.shift();
  37. newWord.pop();
  38. isTitle=true;
  39. break;
  40.  
  41.  
  42. }else{
  43.  
  44. isTitle=false;
  45. }
  46. }
  47.  
  48. }
  49.  
  50.  
  51. word=newWord
  52. if(isTitle){
  53. print(word.join(""));
  54. }else{
  55. print("No such title found!");
  56. }
  57. }
Advertisement
RAW Paste Data Copied
Advertisement