Count all possible strings that can be generated by placing spaces | Java 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 ; Count of positions for spaces ; Count of possible strings ; Driver Code
import java . io . * ; class GFG { static long countNumberOfStrings ( String s ) { int n = s . length ( ) - 1 ; long count = ( long ) ( Math . pow ( 2 , n ) ) ; return count ; } public static void main ( String [ ] args ) { String S = " ABCD " ; System . out . println ( countNumberOfStrings ( S ) ) ; } }