3.7 of 5 908 reviews San Francisco, CA 5000+ Employees Quality Engineer Interview Question

I interviewed in Seattle, WA and was asked:
"Write a Java function that counts the number of "words" in a string, where words are *only* delimited by space characters (no punctuation, very basic). Write unit tests for this function."
Add Tags [?]
Answer Flag Question

Part of a Quality Engineer Interview Review - one of 418 Interview Reviews

Answers & Comments

of 0
static int CountNumberOfWords(char[] arr)
            if (arr.Length < 0)
                return -1;

            int numOfWords = 0;
            bool atWord = false;

            for (int i = 0; i < arr.Length; ++i)
                if (!atWord && arr[i] != ' ') // encounter character
                    atWord = true;
                else if (atWord && arr[i] == ' ')
                    atWord = false;
            return numOfWords;
- Jigargosha on Jul 10, 2012 Flag Response

To comment on this question, Sign In with Facebook or Sign Up – Why Work for Us?'s social and mobile cloud technologies are helping companies connect with their customers, partners and employees in entirely new ways and revolutionizing the way businesses sell, service, market, and… Full Overview

Provided by employer [?]

Tags are like keywords that help categorize interview questions that have something in common.

Glassdoor is your free inside look at interview questions and advice. All interview reviews posted anonymously by employees and interview candidates.