Question:
Given a string, return true if the number of appearances of "is" anywhere in the string is equal to the number of appearances of "not" anywhere in the string (case sensitive).
equalIsNot("This is not") → false
equalIsNot("This is notnot") → true
equalIsNot("noisxxnotyynotxisi") → true
My Solution
public boolean equalIsNot(String str) {int is=0 , not=0;for(int i=0 ; i<str.length(); i++){i=str.indexOf("is",i);if(i!=-1){is++;i++;}elsebreak;}for(int i=0 ; i<str.length(); i++){i=str.indexOf("not",i);if(i!=-1){not++;i=i+2;}elsebreak;}return is==not;}