GithubHelp home page GithubHelp logo

osshu320 / dynamic-programming-questions-by-aditya-verma Goto Github PK

View Code? Open in Web Editor NEW
178.0 4.0 81.0 3.64 MB

Aditya Verma (Youtube) DP Playlist Codes/Solutions.

Home Page: https://www.youtube.com/watch?v=nqowUJzG-iM&list=PL_z_8CaSLPWekqhdCPmFohncHwz8TY2Go

C++ 100.00%
dyanamic-programming recursion memoization knapsack-problem unbounded-knapsack lcs matrix-chain-multiplication diameter-of-binary-tree scs coin-change

dynamic-programming-questions-by-aditya-verma's Introduction

Dynamic-Programming-Questions-by-Aditya-Verma

Codes of all questions covered by Aditya Verma in his Dynamic Programming Lectures
(Codes are tested on gfg / leetcode and are in the order of videos)
Note: Click on title of question to go to the page of code

dynamic-programming-questions-by-aditya-verma's People

Contributors

osshu320 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dynamic-programming-questions-by-aditya-verma's Issues

TestCase Failing for above code

for : count_of_subsets_with_given_sum.cpp (https://github.com/shubhamchemate003/Dynamic-Programming-Questions-by-Aditya-Verma/blob/main/count_of_subsets_with_given_sum.cpp)

is failing for

n=10 
sum=31
arr[] = 9 7 0 3 9 8 6 5 7 6

Working Code :

for(int i=0;i<=sum;i++)
          t[0][i]=0;
            
 t[0][0]=1;
        
        for(int i=1;i<=n;i++){
            for(int j=0;j<=sum;j++){ // j=0 works for above case though I was not able to find the exact reason for same
                if(arr[i-1]<=j)
                    t[i][j]=t[i-1][j] + t[i-1][j-arr[i-1]];
                else
                    t[i][j]=t[i-1][j]%m;
            }
        }

Palindrome Partitioning Memoization

Hey, this repo you have made has helped me a lot, because I get the logic but when it comes to coding it, it sometimes feels difficult, so thank you for making this amazing repo ๐Ÿ™Œ๐Ÿ™Œ.

In this -> https://github.com/shubhamchemate003/Dynamic-Programming-Questions-by-Aditya-Verma/blob/main/pallindrome_partitioning_memoization.cpp

and in this too -> https://github.com/shubhamchemate003/Dynamic-Programming-Questions-by-Aditya-Verma/blob/main/pallindrome_partitioning_memoized_optimization.cpp

just pass the string with reference(&) in both the function ( isPallindrome and Solve) and it will not give TLE .
Just wanted to help, because I think there would be a lot of people like me who are getting help through this repo.

code :

bool isPallindrome(string &X, int i, int j) {
	while (i <= j) {
		if (X[i] != X[j])
			return false;
		i++, j--;
	}

	return true;
}

int Solve(string &X, int i, int j) {
	if (i >= j || isPallindrome(X, i, j)) {
		t[i][j] = 0;
		return 0;
	}

	if (t[i][j] != -1)
		return t[i][j];

	int ans = INT_MAX;
	for (int k = i; k < j; k++) {
		int temp_ans = Solve(X, i, k) + Solve(X, k + 1, j) + 1;
		ans = min(ans, temp_ans);
	}

	return t[i][j] = ans;
} 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.