• + 0 comments

    this is my solution, it works for sample test case 0, but why doesn't it works when i submit the solution, i'm using nodejs, anyone have any idea what did i do wrong?

    function processData(input) {
        //Enter your code here
        const entry = parseInt(input[0])
        const inputString = input.split('\n')
        let phoneBook = {}
        
        for (let i = 1; i <= entry; i++) {
          let items = inputString[i].split(' ');
          phoneBook[items[0]] = items[1]
        }
        
        for (let i = entry + 1; i < inputString.length; i++) {
          if (phoneBook[inputString[i]]) {
            console.log(`${inputString[i]}=${phoneBook[inputString[i]]}`)
          } else {
            console.log('Not found')
          }
        }
    }