SqlSum
Elementry
SELECT sum(v)
FROM elements;
StrSymmetryPoint
Painless
Find a symmetry point of a string, if any.
class Solution {
public int solution(String S) {
int sLen = S.length();
if ((sLen & 1) == 0) {
return -1;
}
final int result = sLen / 2;
for (int i = result, j = result; j >= 0; i++, j--) {
if (S.charAt(i) != S.charAt(j)) {
return -1;
}
}
return result;
}
}
TreeHeight
Painless
class Solution {
int dfs(Tree T) {
if(T == null) return 0;
return Math.max(dfs(T.l), dfs(T.r)) + 1;
}
public int solution(Tree T) {
// write your code in Java SE 11
return dfs(T) - 1;
}
}