Expanse New Grad 2020

You have to basically get the frequency of a token in a message. But the message is split into multiple chunks for optimization.

public int getFrequency(String token, List<String> chunks) {
	// Write the function to return frequency of token
}

Note : You can't join the chunks for solution

Example 1:

Input: token = "foo", chunks = ["foo bar", "foo_fizz bar foo food"]
Output: 3
Explanation: 1 for 1st chunk 2 for the 2nd chunk. We have to split by the nonalphanumeric characters for tokens. 
Also complete token is needed not substring.

Example 2:

Inpput: token = "expanse", chunks: ["abc exp", "anse"]
Output: 1
Explanation: The first chunk and 2nd chunk joined give 1 instance

We need to provide optimal solution keeping in mind massive amount of chunks.

Comments (6)