N-gram Dictionary
Start Timer
0:00:00
Write a function get_ngrams
to take in a word (string) and return a dictionary of n-grams and their frequency in the given string.
Example 1:
Input:
string = 'banana'
n=2
Output:
output = {'ba':1, 'an':2, 'na':2}
Example 2:
Input:
string = 'banana'
n=3
Output:
output = {'ban':1, 'ana':2, 'nan':1}
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments