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 | 729 Views, 22276 Search Bots | 107 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 729 Views, 22276 Search Bots | 107 Words
| 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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 729 Views, 22276 Search Bots | 107 Words 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
Related Articles
- Design Tic-Tac-Toe
- Find Pythagorean Triplets
- Palindrome Integers
- Sort a Partially Sorted List
- [Daily Problem] Validate Balanced Parentheses
- Daily Interview Problem: Maximum Profit From Stocks
- [Daily Problem] Longest Increasing Subsequence
- Algorithm Interview Question: Symmetric k-ary Tree
- Daily Interview Problem: Circle of Chained Words
- Progess made
©2006~2024 SteakOverCooked - 0.01124 Seconds(s) - 1728.975 KB/s - 14 Online Memory: 492.63 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="noindex, 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 !