Count all possible strings that can be generated by placing spaces | C ++ Program to implement the above approach ; Function to count the number of strings that can be generated by placing spaces between pair of adjacent characters ; Length of the string ; Count of positions for spaces ; Count of possible strings ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; long long int countNumberOfStrings ( string s ) { int length = s . length ( ) ; int n = length - 1 ; long long int count = pow ( 2 , n ) ; return count ; } int main ( ) { string S = " ABCD " ; cout << countNumberOfStrings ( S ) ; return 0 ; }