Hii,
This video contains solution of the latest KreditBee Software Engineer Hiring Challenge solution.(Hackerearth)
Question: Count Subsequences
You are given the following:
· An integer N
· A string S of length N
Task:
Count the total number of K periodic subsequences in string S.
Notes
1. Assume 1-based indexing.
2. A string x is called k periodic, if x [I] = x [I + k] for all I from 1 to (|x|+k) |x| means the length of string x.
3. An empty string is also K-periodic.
4. A subsequence is a sequence that can be derived from another sequence deleting some or no elements without changing the order of the remaining elements.
Example:
Assumptions
· N = 4
· K = 2
· S = ”abab”
Approach
All possible K-periodic subsequence are:
· “”
· “ab”,” aa”, ”ab”, ” ba”, ”bb”, ”ab”
· “aba”, “bab”
· “abab”
Therefore, the answer is 14.
I appreciate watching our videos and following along.
Hopefully you have found at least some of it to be helpful to you.
Any feedback is greatly appreciated.
Do like and subscribe for all Upcoming SDE hiring challenges.
Join our telegram group: https://t.me/interviewbuddy
Happy Coding.
#faang
#KreditBee
#hackerearth
#Softwareengineering
#coding
#interview
#hiring