JPMORGAN Coding Question – Solved

3 Live
FunWithAnagrams Two strings are anagrams if they are permutations of each other. In other words, both strings have the same size and the same characters. For example, "aaagmnrs" is an anagram of "anagrams". Given a array of strings, remove each string that is an anagram of an earlier string then return the remaining array in sorted order. Example str = ['code', 'doce', 'ecod', 'framer', 'frame'] - "code" and "doce" are anagrams. Remove "doce" from the array and keep the first occurrence "code" in the array. - "code"and "ecod" are anagrams. Remove "ecod" from the array and keep the first occurrence "code' in the array. - "code" and "framer" are not anagrams. Keep both strings in the array. - "framer" and "frame" are not anagrams due to theextra 'r'in 'framer'. Keep both strings in the array. Β· Order the remaining strings in ascending order: [ "code","frame", "framer"]. Function Description Complete the function funWithAnagrams in the editor below. funWithAnagrams has the following parameters:

Asked in: JPMORGAN

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |