The next video in my iOS Interview questions series all about coding challenges explains a common question that asks you to find the most common element in an array. I have been asked to code this during a phone screen interview and on a whiteboard for an iOS position, so it’s good to know for a variety of reasons.
We solve this Swift coding challenge by iterating over an array and building a dictionary to keep count of each time we find a specific object.
As with all these coding challenges, there are MANY ways to solve this, so if you have improvements to the code please leave a comment so everyone can learn from it.
Follow me on Twitter: