Google interview question

Both: Big-O analysis, optimize, design test cases