To the Top
File:  root - text - article - 2019 - 12 - circle-of-chained-words.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 393 Views, 15517 Search Bots | 107 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Facebook:

Two words can be 'chained' if the last character of the first word is the same as the first character of the second word.

Given a list of words, determine if there is a way to 'chain' all the words in a circle.

Example:
Input: ['eggs', 'karat', 'apple', 'snack', 'tuna']
Output: True
Explanation:
The words in the order of ['apple', 'eggs', 'snack', 'karat', 'tuna'] creates a circle of chained words.

Here's a start:


from collections import defaultdict

def chainedWords(words):
# Fill this in.

print chainedWords(['apple', 'eggs', 'snack', 'karat', 'tuna'])
# True
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 393 Views, 15517 Search Bots | 107 Words Subscribe to Feed Burner

Related Articles

  1. [Daily Problem] Witness of The Tall People
  2. Daily Interview Problem:Create a balanced binary search tree
  3. Fibonacci coding
  4. Algorithm Interview Question: Find the Single Element in an Array of Duplicates
  5. Daily Interview Puzzle: Ways to Traverse a Grid
  6. Daily Interview Problem: Merge K Sorted Linked Lists
  7. Top K Frequent words
  8. [Daily Problem] Remove Consecutive Nodes that Sum to 0
  9. Palindrome Integers
  10. Algorithm Interview: No Adjacent Repeating Characters

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />