Home Tags Posts tagged with "Dynamic Programming"
Tag:

Dynamic Programming

Problems involving dynamic programming or memoization.

  • Theory

    Course on Algorithmic Paradigms

    by nikoo28
    3 minutes read

    Algorithmic Paradigms in short define how you can go about solving a problem. If you are starting to solve problems in computer science, this course is designed for you. However, this course is also recommended for you if you are revising all the basics and want a quick recap of some famous techniques. What are Algorithmic Paradigms? Whenever you try to build something, or develop something, an initial research and foundation is very essential. Think about it, a skyscraper will only be as stable as its base. In the world…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Dynamic programming always reminds of a favorite quotation: Of the several different ways to solve a problem, dynamic programming is a paradigm where we tend to solve the problem as we move ahead and keep on learning. This is one of the techniques which even seasoned programmers find hard to implement. In this post we will try to address some of these fears and aim to have a better understanding of this approach. If you are new to problem solving and somehow landed at this post, it is recommended to…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Arrays

    Maximum sum contiguous sub-array

    by nikoo28
    5 minutes read

    You are provided with an array of integers. We need to find the sub-array with the maximum sum such that all the elements are contiguous. Example:Input: [-2, -5, 6, -2, -3, 1, 5, -6]Output: 7Explanation: The sub-array with maximum sum is [6, -2, -3, 1, 5] Problem Statement: You are provided with an array of integers. These elements could be all positive, all negative or a combination of both. A sub-array is a smaller array formed using the elements of the original array. The condition for this problem is that…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Let us try to simplify the problem as much as we can. We are given with some of the terms. Weights:- According to the problem each character in the English alphabet has been assigned a weight. ‘a’ has been given a weight of 1, ‘b’ has a weight of 2, and so on. The weight of ‘z’ is 26. All the letters are assumed to be lowercase for simplicity. Weight of a string:- This is defined as the sum of all the characters in the string. Example if a string…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Strings

    [HackerRank] – Two Characters

    by nikoo28
    7 minutes read

    A string is said to be valid when it has only distinct characters and none of them repeat simultaneously. For example, if string ‘s two distinct characters are x and y, then valid examples could be xyxyx or yxyxy but not xxyy or xyyx.Question: Given a sample string, we need to determine what is the maximum length of valid string that can be made by deleting any of the characters.Input: beabeefeabOutput: 5 Explanation: Let us try to understand the output for the sample test case.If we delete e and f,…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Strings

    Next lexicographic string permutation

    by nikoo28
    4 minutes read

    Question: Given a string, find the next lexicographic permutation. Input: abcOutput: acb First of all let us try to understand what do you mean by next lexicographic string. To get a hold of the concept try to remember an English dictionary and how words are arranged in it. We start with the letter ‘a’, write all the words and then move to letter ‘b’ all the way to letter ‘z’. This is called as a lexicographic order.This is possible when we have all the letters in English alphabet available to…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Misc

    Find the first N prime numbers. (Method 3)

    by nikoo28
    3 minutes read

    Question: Given an integer N, find the prime numbers in that range from 1 to N. Input: N = 25Output: 2, 3, 5, 7, 11, 13, 17, 19, 23 We discussed the basic approaches to find the first N prime numbers in these posts Find the first N prime numbers (Method 1) Find the first N prime numbers (Method 2) It is advised that you go through the above posts to get a basic understanding of the approach that we have used to determine the prime numbers. Now lets analyze…

    0 FacebookTwitterLinkedinWhatsappEmail

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More