Bird
0
0
DSA Cprogramming~10 mins

Group Anagrams Using Hash Map in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare the hash map variable for grouping anagrams.

DSA C
HashMap* [1] = createHashMap();
Drag options to blanks, or click blank then click option'
AgroupMap
Bmap
CanagramGroups
DhashTable
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like 'map' or 'hashTable' which are less descriptive.
2fill in blank
medium

Complete the code to sort the characters of the string key for grouping anagrams.

DSA C
qsort(key, strlen(key), sizeof(char), [1]);
Drag options to blanks, or click blank then click option'
AcompareChars
BcharCompare
Ccmpfunc
DcompareStrings
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name that does not match the expected qsort comparator signature.
3fill in blank
hard

Fix the error in the code to insert the original string into the hash map under the sorted key.

DSA C
insertHashMap([1], originalStr);
Drag options to blanks, or click blank then click option'
Akey, originalStr
BgroupMap, key
CgroupMap, originalStr
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of arguments or missing the map variable.
4fill in blank
hard

Fill both blanks to check if the sorted key exists in the map and then add the original string to the group.

DSA C
if (hashMapContains([1], [2])) {
    addToGroup([1], [2], originalStr);
}
Drag options to blanks, or click blank then click option'
AgroupMap
Bkey
CoriginalStr
DhashMap
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original string instead of the key for lookup.
5fill in blank
hard

Fill all three blanks to create a new group list for the sorted key and insert the original string.

DSA C
List* newGroup = createList();
addToList(newGroup, [1]);
insertHashMap([2], [3], newGroup);
Drag options to blanks, or click blank then click option'
AoriginalStr
BgroupMap
Ckey
DnewGroup
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of arguments or inserting the wrong variables.