Salesforce | Phone | Count Ducks

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-04-17Added By Anonymous
Source: Link

There are a couple of ducks in a room, they make “quack” sound. Given a string that contains multiple quack words, write a program that returns unique no of ducks in the room. If the string contains incomplete quack word return -1;


//examples

Input: “quackquack” return 2 //two quacks in the string

Input: “qquackuackquack” return 3 // three quacks in the string

Input: “quacqkuack” return 2 //two quacks in the string

Input: “quackqua” return -1 //incomplete quack word in the string

Input: “quackuack” return -1 //incomplete quack word in the string

Input: “qquackuak” return -1 //incomplete quack word in the string

Comments