algorithm wordcount(value prevalue postthe number of words contained within value is determined inw ord true wordcount index /skip initial white space while value[indexwhitespace and index value length - index index end while /was the string just whitespace if index value length and value[indexwhitespace return end if while index value length if value[indexwhitespace /skip all whitespace while value[indexwhitespace and index value length - index index end while inw ord alse wordcount wordcount else inw ord true end if index index end while /last word may have not been followed by whitespace if inw ord wordcount wordcount end if return wordcount end wordcount determining the number of repeated words within string with the help of an unordered setand an algorithm that can split the words within string using specified delimiter this algorithm is straightforward to implement if we split all the words using single occurrence of white space as our delimiter we get all the words within the string back as elements of an array then if we iterate through these words adding them to set which contains only unique strings we can attain the number of unique words from the string all that is left to do is subtract the unique word count from the total number of stings contained in the array returned from the split operation the split operation that we refer to is the same as that mentioned in ss