I would say that extra ;
is the culprit.
Instead
if (s.charAt(i) != h.charAt(t--));
using
if (s.charAt(i) != h.charAt(t--))
You should always take a "safe" route. That is, use curly braces after if-else statements (and almost everywhere you can use them), so errors like this will not happen in the first place. The correct way to write:
if (s.charAt(i) != h.charAt(t--)) {
g++;
}
, , , , s
h
.