Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. #
  2. # Ladder Interview (60 minutes)
  3. #
  4.  
  5. Welcome to the Ladder Interview! The goal of this interview is to implement two
  6. functions described below. You can use whichever programming language you are
  7. most comfortable with or whichever one you think is the best fit for these
  8. problems. After you finish or when you reach 60 minutes attach the source code
  9. files to the email thread. Any late solutions will not be considered.
  10.  
  11. #
  12. # Function 1. is_match (difficulty 1)
  13. #
  14.  
  15. Lets implement a function called `is_match`.
  16.  
  17. `is_match(pattern, input)`
  18. "pattern" is a string where each character is a token.
  19. "input" is a string where each word is a token (space delimited).
  20. return value: boolean which represents whether these two strings match
  21.  
  22. Here are some python examples / test cases:
  23. assert is_match("aba", "red blue red") == True
  24. assert is_match("aaa", "red blue red") == False
  25. assert is_match("aba", "red red red") == False
  26.  
  27. Implement `is_match` with linear runtime O(n + m) where n is the length of
  28. pattern and m is the length of input. You can use any language you want. If you
  29. finish with enough time left then see if you can make your implementation as
  30. clean and concise as possible.
  31.  
  32. #
  33. # Function 2. find_combos (difficulty 2)
  34. #
  35.  
  36. Lets implement a function called `find_combos`.
  37.  
  38. `find_combos(num_desired, available_pack_sizes)`
  39. "num_desired" is an integer and represents the number of sodas that you want.
  40. "available_pack_sizes" is a list of integers and reprents the available pack
  41. sizes a store has.
  42. return value: a list of lists where each entry is a valid combination
  43.  
  44. If you ran find_combos at the python REPL you'd want to see exactly this output:
  45. >>> find_combos(7, [1, 6, 12])
  46. [[1, 1, 1, 1, 1, 1, 1,], [1, 6]]
  47. >>> find_combos(7, [6])
  48. []
  49. >>> find_combos(4, [1, 3])
  50. [[1, 1, 1, 1], [1, 3]]
  51.  
  52. Implement `find_combos` in the simplest way you can. There are no points for
  53. efficiency or runtime in this question. Just focus on solving it in the
  54. cleanest way possible. You can use any language you want. If you finish
  55. everything else with enough time left then see if you can write some type of
  56. upper bound on the runtime (asymptotic runtime complexity).
  57.  
  58. #
  59. # Function 3. is_match_2 (difficulty 3)
  60. #
  61. # This is a BONUS QUESTION. I don't expect you'll be able to get to this
  62. # question and solve it in time.
  63. #
  64.  
  65. Lets implement a function called `is_match_2`.
  66.  
  67. `is_match(pattern, input)`
  68. "pattern" is a string where each character is a token.
  69. "input" is a string.
  70. return value: boolean which represents whether there exists any solution.
  71.  
  72. Here are some python examples / test cases:
  73. assert is_match("ab", "xy") == True
  74. assert is_match("ab", "xxy") == True
  75. assert is_match("ab", "xyy") == True
  76. assert is_match("ab", "xx") == False
  77. assert is_match("aa", "xy") == False
  78.  
  79. Implement `is_match_2` in the simplest way possible. You can use any language
  80. you want. If you finish with enough time left then see if you can make your
  81. implementation as clean and concise as possible.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement