bool is_upper(char a) { if (a >= 'A' && a <= 'Z') return true; return false; } char to_upper(char a) { return (char)(a - 32); } // Complete the abbreviation function below. string abbreviation(string a, string b) { bool success = false; char pre_check = '0'; int checka = 0, checkb = 0; while (checka < a.length()) { if (is_upper(a[checka])) { if (a[checka] != b[checkb]) { if (a[checka] != pre_check) { success = false; break; } } } if (a[checka] == b[checkb] || to_upper(a[checka]) == b[checkb]) { if (is_upper(a[checka])) pre_check = a[checka]; else pre_check = to_upper(a[checka]); checkb++; if (checkb == b.length()) { success = true; for (int i = checka + 1; i < a.length(); i++) { if (is_upper(a[i])) { success = false; break; } } break; } } checka++; } if (success) return "YES"; else return "NO"; }