• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 03, 2023 |2.3K Views
PROBLEM OF THE DAY: 02/10/2023 | Number of distinct subsequences
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Devashish Khare. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Dynamic Programming but will also help you build up problem-solving skills.

In this problem, we are given, a string consisting of lower case English alphabets, the task is to find the number of distinct subsequences of the string
Note: Answer can be very large, so, ouput will be answer modulo 109+7.

Example :

Input: 
s = "gfg"
Output: 
7

Explanation: 
The seven distinct subsequences are "", "g", "f", "gf", "fg", "gg" and "gfg" .

Give the problem a try before going through the video. All the best!!!

Problem Link: https://practice.geeksforgeeks.org/problems/number-of-distinct-subsequences0909/1