There were two problem statements to be solved in 1 hour:
1. Perfect Substring
Count the number of substring that contain all digits exactly k times or 0 times.
Eg: If k=2: Valid string is 001122 Invalid String is 00112
Length of string<= 1e5
1<=k<=1e4
2. Hate Graphs
You are given a list of species numbered 1 to n. You have two arrays a and b. For all i, a[i] and b[i] hate each other. Find the number of ways you can keep these species in enclosures such that no pair of species who hate each other are in the same enclosure.
Example:
Input: n = 3, a = [1, 2] b = [2, 3]
Output: 4
Explanation: {1}, {2}, {3}, {1,3} are the possible groups into which you can divide the species. Each bracket here represents a separate enclosure.I was unable to solve the second problem statement and would be grateful if someone could help me out come up with a solution.