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 | 464 Views, 22732 Search Bots | 107 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 464 Views, 22732 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 | 464 Views, 22732 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 Problem] Angles of a Clock
- Algorithm Interview: Longest Consecutive Sequence
- Non-decreasing Array with Single Modification
- Daily Interview Problem: Longest Substring With K Distinct Characters
- Spreadsheet Columns
- Algorithm Interview Question: H-Index
- [Daily Problem] Witness of The Tall People
- Sorting a list with 3 unique numbers
- [Daily Problem] Remove Consecutive Nodes that Sum to 0
- Staying on a Chess Board
©2006~2024 SteakOverCooked - 0.01602 Seconds(s) - 1237.39 KB/s - 40 Online Memory: 492.49 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 !