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, 17176 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, 17176 Search Bots | 107 Words Subscribe to Feed Burner

Related Articles

  1. Palindrome Integers
  2. Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
  3. Daily Interview Problem: 3 Sum
  4. Algorithm Interview: Determine If Linked List is Palindrome
  5. Autorun.inf Virus Protection
  6. Daily Interview Problem: Deepest Node in a Binary Tree
  7. Daily Interview Problem: Merge Overlapping Intervals
  8. Daily Interview Problem:Create a balanced binary search tree
  9. Fix Brackets
  10. Daily Interview Problem: Group Words that are Anagrams

Comments (0)

    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" />