leetcode Group Anagrams

Given an array of strings, group anagrams together.

For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],
Return:

[
[“ate”, “eat”,”tea”],
[“nat”,”tan”],
[“bat”]
]
Note: All inputs will be in lower-case.

题目地址:leetcode Group Anagrams

题目大意: 给定一些字符串,有的字符串是由字符串颠倒的,比如eat->tea 要求找出所有的这些单词

思路:直接用将每个字符串放入排好序后的桶中(hash)即可。

C++

Python

 

本文是leetcode如下的题解

  • 49. Group Anagrams

更多题解可以查看: https://www.hrwhisper.me/leetcode-algorithm-solution/

本博客若无特殊说明则由 hrwhisper 原创发布
转载请点名出处:细语呢喃 > leetcode Group Anagrams
本文地址:https://www.hrwhisper.me/leetcode-anagrams/

打赏一杯咖啡钱呗

codes, Leetcode , , , . permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *