oh look it's a hashmap

Posted by r0tiart on March 10, 2018

So i’ve been going through the questions in chapter1 of Cracking the Coding Interview and chapter 1 is Arrays and Strings. The solutions in which I come up with primarily consists of mapping the array with their elements into a hashmap. And then from there I would either compare the second array to the map - and return false if necessary.

If it’s just one array, I may still use a hashmap to map the array and then analyze / go through the hashmap and to figure out what is happening. It is starting to slowly becomming the most recognizable pattern to use (for me at least) for strings and arrays. - for strings, I would first have to split the string into an array - then use the hashmap method.

If returning a string is necessary - i would just join the array to return. While working on the questions it has become slowly easier to notice when to use a hashmap or when a hashmap can be useuful.

It did take the entire first chapter of questions to figure that out, skipping two questions that involve matrixs - i’ll have to read through the hints to understand matrix questions.