Given a list of strings, find the largest string among all. Largest string is the string with largest number of unique characters.
Input : "AN KOW", "LO JO", "ZEW DO RO" Output : "ZEW DO RO" Explanation : "ZEW DO RO" has maximum distinct letters. Input : "ROMEO", "EMINEM", "RADO" Output : "ROMEO" Explanation : In case of tie, we can print any of the strings.
We iterate over the strings, and take a boolean array to check the presence of letters. Also, keep track of maximum unique letters. Return the string with maximum number of distinct characters.
A AB C JOHNSON
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Minimum deletions from string to reduce it to string with at most 2 unique characters
- Minimize number of unique characters in string
- Permutation of a string with maximum number of characters greater than its adjacent characters
- Find the longest substring with k unique characters in a given string
- Efficiently check if a string has all unique characters without using any additional data structure
- Python program to check if a string contains all unique characters
- Determine if a string has all Unique Characters
- Find all unique pairs of maximum and second maximum elements over all sub-arrays in O(NlogN)
- Longest substring with K unique characters using Binary Search
- Count of all unique substrings with non-repeating characters
- Maximum non-repeating characters after removing K characters
- Min flips of continuous characters to make all characters same in a string
- String with k distinct characters and no same characters adjacent
- Rearrange the characters of the string such that no two adjacent characters are consecutive English alphabets
- Count of ungrouped characters after dividing a string into K groups of distinct characters
- Minimum cost to remove the spaces between characters of a String by rearranging the characters
- Maximum number of unique values in the array after performing given operations
- Maximum number of unique Triplets such that each element is selected only once
- Replace minimal number of characters to make all characters pair wise distinct
- Minimum number of operations to move all uppercase characters before all lower case characters
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.