We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
set(a).intersection(b) creates a list with a single occurance of the common characters between the two strings. Then iterate over each character of ab_intersection to determine the least number in either string. Summing the minimum occurance of common characters allows you to calculate how many characters to remove.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
set(a).intersection(b) creates a list with a single occurance of the common characters between the two strings. Then iterate over each character of ab_intersection to determine the least number in either string. Summing the minimum occurance of common characters allows you to calculate how many characters to remove.