Sparse Arrays

  • + 0 comments

    TypeScript

    function matchingStrings(strings: string[], queries: string[]): number[] {
        // Write your code here
        let result = [];
        for (let i = 0; i < queries.length; i++)
        {
            let counter = 0;
            for (let j = 0; j < strings.length; j++)
            {
                if (queries[i] == strings[j])
                {
                    counter++;
                }
            }
            result.push(counter);
        }
        
        return result;
    }