question: public static String removeConsecutiveDuplicates ( String s ) { String previous = "??" ; StringBuffer result = new StringBuffer ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String c = s . charAt ( i ) + "" ; if ( ! previous . equalsIgnoreCase ( c ) ) { result . append ( c ) ; } previous = c ; } return result . toString ( ) ; }
target:  Replaces consecutive instances of characters with single instances. Case-insensitive.