Posts

Showing posts from November, 2017

Dynamic Programming: Basics and a Practical Example

Introduction: Dynamic programming is a problem-solving technique that can seem quite intimidating at first glance. However, once you grasp its fundamentals and see it in action, you'll find it to be a powerful tool in your coding arsenal. In this blog post, we'll demystify the basics of dynamic programming and walk through a practical example. We'll provide you with clear explanations and a complete Python program, so you can understand and apply this essential concept with confidence. Understanding Dynamic Programming: At its core, dynamic programming is all about breaking down a complex problem into smaller, overlapping subproblems. It's a technique used to efficiently solve problems by storing and reusing solutions to these subproblems, rather than recomputing them. This leads to significant improvements in runtime complexity. Example: Fibonacci Sequence with Dynamic Programming Let's start by tackling a classic problem: calculating Fibonacci numbers. The Fibonac...

Morgan Stanley Campus Codeathon 2017

Q-1 Maximize Profit Crypto Bank provides   crypto currencies, each of which has a fixed conversion rate with respect to dollar. The conversion rate w.r.t dollar is not subject to change over time. But as you may have imagined, the conversion rate between each pair of crypto currencies may change over time, due to economic and political factors. Ron has   bitcoins with him. The conversion rate of a bitcoin w.r.t dollar is  . You are given the conversion rates of every other crypto currency with respect to bitcoin. You are also given the conversion rate of these crypto currencies w.r.t dollar. You have to find the currency, that Ron can buy with   bitcoins, such that the total value in dollars is maximized. Note that, Ron cannot buy crypto currency in fractions and Ron can own only one type of crypto currency at the end of the transaction. Input Format In the first line, you are given three integers -  ,   and...

HourRank 24 - Hackerrank - 2-Nov-2017

Q-1 Strong Password Louise joined a social networking site to stay in touch with her friends. The signup page required her to input a  name  and a  password . However, the password must be  strong . The website considers a password to be  strong  if it satisfies the following criteria: - Its length is at least  . - It contains at least one digit. - It contains at least one lowercase English character. - It contains at least one uppercase English character. - It contains at least one special character. The special characters are:  !@#$%^&*()-+ She typed a random string of length   in the password field but wasn't sure if it was strong. Given the string she typed, can you find the minimum number of characters she must add to make her password strong? Note : Here's the set of types of characters in a form you can paste in your solution: numbers = 0 to 1 lower_case = a to z upper_case = A to Z special_c...