Mock Test 2 JS

Is it just me or is there a bug that causes the time limit to expire before it actually expires?
Or am I doing something wrong?

1 Like

I think I got my answer. The time limit had not expired, the execution of the code had exceeded the time limit constraint as explained in this thread.

1 Like

Try with this solution :
let anagram = gets().split(’’).sort();

 let n = +gets();



 for (let i = 0; i < n; i++) {

   let word = gets().split('').sort();



   if (anagram.length !== word.length) {

     print('No')

   } else {

     let isAnagram = true;



     for (let j = 0; j < anagram.length; j++) {

       if (anagram[j] !== word[j]) {

         isAnagram = false;

         break;

       }

     }



     if (isAnagram) {

       print('Yes');

     } else {

       print('No');

     }

   }

 }