There are a few problems. First you will reassign the value if you find more than 1 Maryland's and second if it finds it then the next word isn't it will say you didn't find.
Part two is really easy to fix. Remove the else statement and initialize whenOccurs to -1 which will set the default value to -1 (not found).
The first part is also a pretty simple fix. You are going to need to either set a variable to keep track of first variable found or break out of the loop either adding a second condition i < n && WhenOccurs == -1 or
1 2 3 4 5
if( o[i] == maryland )
{
whenOccurs = i;
break;
}
or
1 2
if( o[i] == maryland )
return i;
I would probably do the first method though.
Also I just noticed a 3rd error. Your parameter for size is t but in the for loop you have n?