Skip to content

Instantly share code, notes, and snippets.

@kattak
Last active September 27, 2017 11:43
Show Gist options
  • Save kattak/5c27ab69a8bdc03c862502123adc3fc3 to your computer and use it in GitHub Desktop.
Save kattak/5c27ab69a8bdc03c862502123adc3fc3 to your computer and use it in GitHub Desktop.
Aug 29 WWC Technical Interviewing and Algorithms Workshop - focus: Dynamic Programming

Hi everyone, Thanks for a lovely and productive session this week.

Covered -

Dynamic Programming

  1. Find max of array

  2. Stock price: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/

  3. Ways to climb stairs: http://www.geeksforgeeks.org/count-ways-reach-nth-stair/

  4. Discussion: Fibonacci with memoization, only two variables http://www.geeksforgeeks.org/program-for-nth-fibonacci-number/

  5. Rob houses (also see my solution below): http://www.geeksforgeeks.org/find-maximum-possible-stolen-value-houses/

def rob(nums):
    if len(nums) == 0:  return 0
    if len(nums) <= 2:  return max(nums)

    max_money = [0] * len(nums)
    max_money[0] = nums[0]
    max_money[1] = max(nums[0], nums[1])

    for house in xrange(2, len(nums)):
        max_money[house] = max(max_money[house-1], max_money[house-2]+nums[house])

    return max_money
  1. Mentioned: Knapsack problem http://www.geeksforgeeks.org/knapsack-problem/

Resources discussed:

  1. HackerRank/Leetcode
  2. Pramp https://www.pramp.com/#/
  3. Coderbyte https://coderbyte.com/CodingArea/Profile/

4.Upcoming technical interview workshop with the author of Cracking the Coding Interview: https://www.eventbrite.com/e/slack-devs-meetup-august-tickets-36901245619?utm_source=eb_email&utm_medium=email&utm_campaign=order_confirmation_email&utm_term=eventname&ref=eemailordconf

It's tomorrow! Aug 29

Let me know if I missed anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment