using vectors, passed all test, 45seconds