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, 22735 Search Bots | 107 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 464 Views, 22735 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, 22735 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
- Algorithm Interview: Level Order Traversal of Binary Tree
- 56 Bytes
- Daily Interview Problem: Longest Substring With K Distinct Characters
- Fibonacci coding
- Daily Interview Problem: Reverse Words in a String
- Palindrome Integers
- Daily Interview Problem: Running Median
- Daily Interview Problem: Find the Number of Islands
- [Daily Problem] Course Prerequisites
- [Daily Problem] Add two numbers as a linked list
©2006~2024 SteakOverCooked - 0.00788 Seconds(s) - 2576.365 KB/s - 27 Online Memory: 493.95 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="index, 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 !