Pergunta de entrevista da empresa Google

Check whether the string is symmetric, how to test your result

Respostas da entrevista

Sigiloso

18 de jan. de 2011

actually yo do not need to break from the algorithm, just return false when you find they are different, then return true after the iteration.

2

Sigiloso

31 de mar. de 2011

boolean isSymetric(String str) { for (int i=0; i

1

Sigiloso

27 de jan. de 2011

The code is close to correct but will never return true

Sigiloso

31 de mar. de 2011

#include #include using namespace std; bool isSymmetric(string str) { int len = str.length(); int i = 0; int j = len -1; do { if (str[i] == str[j]) { i++; j--; } else { return false; } } while(i> str; cout <

Sigiloso

15 de jan. de 2011

#include #include using namespace std; bool isSymmetric(string str) { int len = str.length(); for(int i=0;i> str; cout << isSymmetric(str); return 0; }

Sigiloso

15 de jan. de 2011

i is in scope of for, so u need to define i earlier to access it later!