To the Top
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 | 168 Views, 15843 Search Bots | 77 Words

Subscribe to Feed Burner | 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:


import collections

def groupAnagramWords(strs):
# Fill this in.

print groupAnagramWords(['abc', 'bcd', 'cba', 'cbd', 'efg'])
# [['efg'], ['bcd', 'cbd'], ['abc', 'cba']]
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 168 Views, 15843 Search Bots | 77 Words Subscribe to Feed Burner

Related Articles

  1. Number of Ways to Climb Stairs
  2. Algorithm Interview: No Adjacent Repeating Characters
  3. Reverse a Directed Graph
  4. [Daily Problem] Course Prerequisites
  5. Algorithm Interview: Level Order Traversal of Binary Tree
  6. Daily Interview Problem: Look and Say Sequence
  7. Daily Interview Puzzle: Falling Dominoes
  8. Daily Interview Puzzle: Intersection of Linked Lists
  9. Most Frequent Subtree Sum
  10. Daily Interview Problem: Trapping Rainwater

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />