others Python data science interview prep

Indeed

Bigrams

Interview Query

Write a function that takes in a string and returns a list of bigrams.

Input: 
  sentence = """
  Have free hours and love children? 
  Drive kids to school, soccer practice 
  and other activities.
  """
Output:
  [('have', 'free'),
  ('free', 'hours'),
  ('hours', 'and'),
  ('and', 'love'),
  ('love', 'children?'),
  ('children?', 'drive'),
  ('drive', 'kids'),
  ('kids', 'to'),
  ('to', 'school,'),
  ('school,', 'soccer'),
  ('soccer', 'practice'),
  ('practice', 'and'),
  ('and', 'other'),
  ('other', 'activities.')]

See my solution here.


Starbucks

Stock profit

Interview Query

Given a list of stock prices and their corresponding dates (in ascending order by date), write a function that outputs the possible max profit and its buy / sell dates.

Input:
  stock_prices = [10,5,20,32,25,12]
  dts = [
      '2019-01-01', 
      '2019-01-02',
      '2019-01-03',
      '2019-01-04',
      '2019-01-05',
      '2019-01-06',
  ]

Output:
  get_profit_dates(stock_prices, dts) -> (27, '2019-01-02', '2019-01-04')

See my solution here.