Skip to content

Instantly share code, notes, and snippets.

@rahul4coding
Last active January 24, 2023 18:21
Show Gist options
  • Save rahul4coding/64023e39017f0a5915a9ff884d18446d to your computer and use it in GitHub Desktop.
Save rahul4coding/64023e39017f0a5915a9ff884d18446d to your computer and use it in GitHub Desktop.
Sparse Arrays Hackerrank Solution by Rahul Bhatija
// https://www.hackerrank.com/challenges/sparse-arrays
// Simple JavaScript solution
function matchingStrings(strings, queries) {
return queries.map(x=>strings.filter(y=>y===x).length)
}
@standardbiblio-ng
Copy link

this is brillient i like your code ๐Ÿ‘Œ

@standardbiblio-ng
Copy link

this is brillient i like your code ๐Ÿ‘Œ

@kennyiki
Copy link

Hello could you please explain how the code works? I Looked at the problem I have no clue how to solve it.

@19sajib
Copy link

19sajib commented Sep 2, 2022

wow,, this is awesome

@ahtisham225
Copy link

ahtisham225 commented Jan 24, 2023

Sparse arrays hackerrank solution JavaScript and Python

You just have to iterate over the values in queries and check through .count function that particular value exist in stringList or not.
https://hecodesit.com/sparse-arrays-hackerrank-solution-javascript-and-python/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment