File: root - text - article - 2019 - 12 - group-words-that-are-anagrams.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 456 Views, 20245 Search Bots | 77 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 456 Views, 20245 Search Bots | 77 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by AirBNB:
Given a list of words, group the words that are anagrams of each other. (An anagram are words made up of the same letters).
Example:
Input: ['abc', 'bcd', 'cba', 'cbd', 'efg']
Output: [['abc', 'cba'], ['bcd', 'cbd'], ['efg']]
Here's a starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 456 Views, 20245 Search Bots | 77 Words Given a list of words, group the words that are anagrams of each other. (An anagram are words made up of the same letters).
Example:
Input: ['abc', 'bcd', 'cba', 'cbd', 'efg']
Output: [['abc', 'cba'], ['bcd', 'cbd'], ['efg']]
Here's a starting point:
import collections
def groupAnagramWords(strs):
# Fill this in.
print groupAnagramWords(['abc', 'bcd', 'cba', 'cbd', 'efg'])
# [['efg'], ['bcd', 'cbd'], ['abc', 'cba']]
Related Articles
- Daily Interview Problem: Merge List Of Number Into Ranges
- Daily Interview Problem: Count Number of Unival Subtrees
- Daily Interview Problem: Min Stack
- Daily Interview Problem: Min Range Needed to Sort
- Making a Height Balanced Binary Search Tree
- Sort a Partially Sorted List
- Algorithm Interview Question: Nth Fibonacci Number
- Daily Interview Problem: Reverse Words in a String
- Invert a Binary Tree
- Daily Interview Problem: Room scheduling
©2006~2024 SteakOverCooked - 0.00704 Seconds(s) - 2879.771 KB/s - 40 Online Memory: 494.02 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !