Tech Off Post

Single Post Permalink

View Thread: Coding Interview Question
  • User profile image

    An old co-worker uses this as his interview question and I'm curious about how you might solve it.

    "Given an array of integers, find the mean and the frequency"

    The mean is very simple, but the frequency part is where different methodologies can come in.  Feel free to show and explain your process.  There is no right or wrong way, it's just a test of your intelligence/creativity.  

    //TODO: Find the frequency
    int[] intArray
    int meanDivisor = intArray.Count();
    int meanToBeDivided = 0;
    foreach(int number in intArray)
        meanToBeDivided += number;
    var mean = meanToBeDivided / meanDivisor;