有什么简单的方法可以判断一个单词列表是否是彼此的字谜? [英] What is an easy way to tell if a list of words are anagrams of each other?

查看:81
本文介绍了有什么简单的方法可以判断一个单词列表是否是彼此的字谜?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您将如何列出彼此的字词的单词?

How would you list words that are anagrams of each other?

我申请当前工作时被问到这个问题.

I was asked this question when I applied for my current job.

orchestra可以重新排列成carthorse,所有原始字母都只能使用一次,因此这些单词是彼此的字谜.

orchestra can be rearranged into carthorse with all original letters used exactly once therefore the words are anagrams of each other.

推荐答案

将所有字母按字母顺序放入字符串中(排序算法),然后比较结果字符串.

Put all the letters in alphabetical order in the string (sorting algorithm) and then compare the resulting string.

-亚当

这篇关于有什么简单的方法可以判断一个单词列表是否是彼此的字谜?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆