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 | 394 Views, 15640 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 | 394 Views, 15640 Search Bots | 107 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Look and Say Sequence
  2. [Daily Problem] Longest Increasing Subsequence
  3. Daily Interview Problem: Largest Product of 3 Elements I
  4. Daily Interview Problem: Running Median
  5. Daily Interview Problem: Decode String
  6. Daily Interview Question: Longest Sequence with Two Unique Numbers
  7. [Daily Problem] Add two numbers as a linked list
  8. Staying on a Chess Board
  9. Floor and Ceiling of a Binary Search Tree
  10. Daily Interview Problem: Queue Using Two Stacks

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" />