File: root - text - article - 2019 - 12 - word-ordering-in-a-different-alphabetical-order.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 479 Views, 23163 Search Bots | 107 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 479 Views, 23163 Search Bots | 107 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Apple:
Given a list of words, and an arbitrary alphabetical order, verify that the words are in order of the alphabetical order.
Example:
Input:
Output: False
Explanation: 'e' comes before 'a' so 'efgh' should come before 'abcd'
Example 2:
Input:
Output: True
Explanation: The words are in increasing alphabetical order
Here's a starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 479 Views, 23163 Search Bots | 107 Words Given a list of words, and an arbitrary alphabetical order, verify that the words are in order of the alphabetical order.
Example:
Input:
words = ["abcd", "efgh"], order="zyxwvutsrqponmlkjihgfedcba"
Output: False
Explanation: 'e' comes before 'a' so 'efgh' should come before 'abcd'
Example 2:
Input:
words = ["zyx", "zyxw", "zyxwy"],
order="zyxwvutsrqponmlkjihgfedcba"
Output: True
Explanation: The words are in increasing alphabetical order
Here's a starting point:
def isSorted(words, order):
# Fill this in.
print isSorted(["abcd", "efgh"], "zyxwvutsrqponmlkjihgfedcba")
# False
print isSorted(["zyx", "zyxw", "zyxwy"],
"zyxwvutsrqponmlkjihgfedcba")
# True
Related Articles
- Daily Interview Problem: Validate Binary Search Tree
- Daily Interview Problem: Look and Say Sequence
- Algorithm Interview: Smallest Number that is not a Sum of a Subset of List
- Algorithm Interview: Permutations of numbers
- Daily Interview Problem: Count Number of Unival Subtrees
- [Daily Problem] Move Zeros
- Windows Scripting
- Progess made
- [Daily Problem] Angles of a Clock
- Compare Version Numbers
©2006~2024 SteakOverCooked - 0.01094 Seconds(s) - 1738.035 KB/s - 38 Online Memory: 493.13 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 !