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

Related Articles

  1. Daily Interview Puzzle: Intersection of Linked Lists
  2. Algorithm Interview: Permutations of numbers
  3. Fibonacci coding
  4. Algorithm Interview Question: Find the Single Element in an Array of Duplicates
  5. How to Play WAV music under DOS?
  6. Daily Interview Problem: Find the k-th Largest Element in a List
  7. Algorithm Interview: Convert Roman Numerals to Decimal
  8. Daily Interview Question: Create a Simple Calculator
  9. CVE-2015-8874 - cPanel EasyApache Vulnerabilities
  10. Fix Brackets

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />