算法题: 打印含有相同字符的数组

Write a function that takes as input list of words and prints out groups of words with exactly the same letters, one group per line.

For example,

Given the list:
hat, top, potter, pot, pier, ripe

It would print:
hat
top, pot
potter,
pier, ripe

Since ‘pier’ and ‘ripe’ each have one p, i, e, and r they belong on the same line. Since no other word has the same 6 letters as ‘potter’ it belongs on a line by itself.

Note: The order of the lines does not matter. As long as all words that belong on the same line are grouped together the function is correct.

Please use the following function signature:

void PrintGroupsWithSameLetters(string[] words)

 

http://www.iteye.com/topic/1120051

 

你可能感兴趣的:(group,alograms,算法题)