Below 2 Questions were asked during the coding round for Salesforce Interview.
1. A list of words is given & we need to find the number of anagram groups can be made.
e.g. : "cat", "tac", "owl", "low", "act"
Here we can make 2 anagram groups : cat, tac, act
owl, low
Result : 2
Though I gave the solution in imperative style to avoid any hiccups during the execution but FP way is given below-
1. A list of words is given & we need to find the number of anagram groups can be made.
e.g. : "cat", "tac", "owl", "low", "act"
Here we can make 2 anagram groups : cat, tac, act
owl, low
Result : 2
Though I gave the solution in imperative style to avoid any hiccups during the execution but FP way is given below-
2. Given two strings s and t, return the number of distinct subsequences of s which equals t.
1 <= s.length() <= 5*100000
t.length() == 3
e.g. t = abc
s = abdcabbc
Result : 6
It is a variant of Distinct Subsequences - LeetCode
I was not able to provide the optimal solution, below is the solution, tested for above leetcode problem -
1 <= s.length() <= 5*100000
t.length() == 3
e.g. t = abc
s = abdcabbc
Result : 6
It is a variant of Distinct Subsequences - LeetCode
I was not able to provide the optimal solution, below is the solution, tested for above leetcode problem -