That's not O(n). Unless you define n as the product of the string lengths, which would be very weird.