Tag Archives: Dynamic Programming

Count Distinct Subsequences

Given a string, find count of distinct subsequences of it. Examples: Input : str = “gfg” Output : 7 The seven distinct subsequences are “”, “g”, “f”, “gf”, “fg”, “gg” and “gfg” Input : str = “ggg” Output : 4 The six distinct subsequences are “”, “g”, “gg” and “ggg” The problem of counting distinct… Read More »