To the Top
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 | 189 Views, 17187 Search Bots | 107 Words

Subscribe to Feed Burner | 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:

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
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 189 Views, 17187 Search Bots | 107 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Room scheduling
  2. Daily Interview Problem: Sort Colors
  3. Design Tic-Tac-Toe
  4. [Daily Problem] Witness of The Tall People
  5. Daily Interview Question: Longest Sequence with Two Unique Numbers
  6. Plus One
  7. Daily Interview Problem: Full Binary Tree
  8. Daily Interview Problem: Deepest Node in a Binary Tree
  9. Maximum In A Stack
  10. Batch Programming in XP

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />