I went through your solutions and I must disagree. Your solutions did not generate the correct output for the questions.
For example, I'll take the following question :
'Given the string variable 's' and the integer 'n', return a new string consisting of n repetitions of s.
For example, if s = "abc" and n = 3, you should return "abcabcabc".'
The code you have written is as follows :
String duplicate(String s, int n)
{
String result = s;
// First assignment already done
while (n > 0) {
result += s;
n--;
}
return result;
}
If we analyze the following code (assuming that s = "abc" and n = 3), initially, the variable 'result' is assigned the value "abc".
The loop then runs 3 times - when n = 3, when n = 2 and when n = 1. Which effectively means that "abc" is concatenated 3 more times giving the string "abcabcabcabc", which is incorrect.
I do agree that the solution is almost right. Note that you are allowed to compile your code and run it against our testdata (and even your own test cases) in order to establish it's correctness - which means that you did have the opportunity to find out that there was a bug in your code and fix it.
But in computing, how often is it acceptable to get things 'almost' right ? Would you be happy if Google returned search results which were almost right ?
I know that if a human conducted the interview, he would have helped guide you through the test - in fact, we are almost done adding the capability for recruiters to monitor test sessions in real time and converse with candidates.
I can also provide a case by case analysis of your other solutions if you wish.