Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. let N = +readline();
  2. const subseq = [];
  3.  
  4. while (N--) {
  5. subseq.push(readline());
  6. }
  7. function getAllSubstrings(str) {
  8. var i, j, result = [];
  9.  
  10. for (i = 0; i < str.length; i++) {
  11. for (j = i + 1; j < str.length + 1; j++) {
  12. result.push(str.slice(i, j));
  13. }
  14. }
  15. return result;
  16. }
  17. let arr=[]
  18. for(let i =0;i<subseq.length;i++){
  19. arr.push(getAllSubstrings(subseq[i]))}
  20. // Write an action using console.log()
  21. // To debug: console.error('Debug messages...');
  22.  
  23. function intersect(a, b) {
  24. var setB = new Set(b);
  25. return [...new Set(a)].filter(x => setB.has(x));
  26. }
  27. if(subseq.length===2){
  28. arr2 = intersect(arr[0],arr[1])
  29. print(subseq[1].length-arr2.length+subseq[0].length)}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement