Git Product home page Git Product logo

codehelp-dsa-busted-series's Introduction

CodeHelp-DSA-Busted-Series

Hello Jee,

This repo is for the students for easy access to all the programs taught under Codehelp's DSA Busted Series.

DSA Busted Series

Youtube Channel: CodeHelp - by Babbar

Your Instructor: Love Babbar

Learn a Lot, Enjoy a Lot.

codehelp-dsa-busted-series's People

Contributors

deepakkumar-1 avatar devesh-sharma-01032008 avatar heyyitsmanan avatar iamaakashthakur avatar imsushant12 avatar jai-bhardwaj avatar jainendra-mahajan avatar kailashchandra avatar kawalpreettkaur avatar kishanrajput23 avatar lovebabbar avatar mohd-aajam avatar raushanstar avatar softhackpro avatar sreekaran1704 avatar sumanthhabib96 avatar supersaint7780 avatar thepranaygupta avatar yajnesh99 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  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

codehelp-dsa-busted-series's Issues

Lecture 13

link - https://youtu.be/zD2Jg3alZV8

i have try this in c language but it's not working i don't know why .

code--------------------------------------------------------------
#include<stdio.h>

int mai(int arr[] , int size , int key){
int start = 0 ;
int end = size -1 ;

int mid = start +(end-start)/2;

while(start <=end)
{
if ( arr[mid]== key)
{
/* code /
return mid;
}
if (key > arr[mid]){
start = mid + 1;
// return mid;
}
else {
end = mid -1;
// return mid;
/
code */
}
mid = start + (end - start)/2;
}
return -1;
}

int main(){
int even[6] = {9 , 98, 88,1,17,19};
int odd[5] = {8,2, 99,89,87};
int index = mai(even,6,1);
printf("Index of 98 is %d " , index );

}

please check if a am wrong some where . thank for binary seach lectures .

Allocate Books

import java.util.*;
public class Solution {
public static boolean ispossible(ArrayList arr, int n, int m,int mid){
int studentCount=1;
int pageSum= 0;
for(int i=0;i<n;i++){
if(pageSum+arr.get(i)<=mid){
pageSum+=arr.get(i);
}
else {
studentCount++;
if(studentCount>m||arr.get(i)>mid){
return false;
}
pageSum=arr.get(i);
}
}
return true;
}
public static int allocateBooks(ArrayList arr, int n, int m) {
// Write your code here.
int s=0;
int sum=0;
for(int i=0;i<n;i++){
sum+=arr.get(i);
}
int e=sum;
int ans=-1;
int mid=s+(e-s)/2;
while(s<=e){
if(ispossible(arr,n,m,mid)){
ans=mid;
e=mid-1;
}
else{
s=mid+1;
}
mid=s+(e-s)/2;
}
return ans;
}
}

Adding Python language

I wish to contribute DSA using Python Language, So is it possible to contribute here?

Book allocation problem- the test cases are not passing

https://practice.geeksforgeeks.org/problems/allocate-minimum-number-of-pages0937/1
In this problem, the 11th test case is not passing.
code:

class Solution 
{
    public:
    bool isPossible(int arr[], int n, int m, int mid)
    {
        int studentCount = 1;
        int pageSum = 0;
        for(int i=0; i<n; i++)
        {
            if(pageSum+arr[i] <= mid)
            {
                pageSum += arr[i];
            }
            else
            {
                studentCount++;
                if(studentCount > m || arr[i]>mid)
                {
                    return false;
                }
                pageSum = arr[i];
            }
        }
        return true;
    }
    //Function to find minimum number of pages.
    int findPages(int arr[], int n, int m) 
    {
        //code here
        int s = 0;
        int sum = 0;
        for(int i=0; i<n; i++)
        {
            sum+=arr[i];
        }
        int e = sum;
        int ans = -1;
        int mid = s + (e-s)/2;
        while(s<=e)
        {
            if(isPossible(arr, n, m, mid))
            {
                ans = mid;
                e = mid-1;
            }
            else
            {
                s = mid+1;
            }
            mid = s+(e-s)/2;
        }
        return ans;
    }
};

Incorrect c++ code in deleteFromBst.cpp

Existing Code by CodeHelp

I/P - 30 80 40 50 -1
This code doesn't works for, when you delete 30

int Height(Node* root){
    int x, y;
    if(root == NULL){
        return 0;
    }
    x = Height(root->left);
    y = Height(root->right);
    return x>y?x+1:y+1;
}

Node* deleteFromBst(Node* root, int val)
{
    // base case
    if(root == NULL){
        return root;
    }

    if(root->data == val){
        // 0 child
        if(root->left == NULL && root->right == NULL){
            delete root;
            return NULL;
        }
        
        // 1 child

            // left child
        if(root->left != NULL && root->right == NULL){
            Node* temp = root->left;
            delete root;
            return temp;
        }

            // right child
        if(root->left == NULL && root->right != NULL){
            Node* temp = root->right;
            delete root;
            return temp;
        }

        // 2 child
        if(root->left != NULL && root->right != NULL){
            if(Height(root->left) > Height(root->right)){
                int maxi = maxVal(root->left)->data;    // find predecessor of root(right child of left subtree)
                root->data = maxi;    // copy the value of right most child of left subtree in root->data
                root->left = deleteFromBst(root->left, maxi);    // now delete recursively the right most child of left subtree
            }
            else
            {
                int mini = minVal(root->right)->data;          // find successor of root(left child of right subtree)
                root->data = mini;         // copy the value of left most child of right subtree in root->data
                root->right = deleteFromBst(root->right, mini);    // now delete recursively the left most child of right subtree
            }
        }

    }
    else if(root->data > val){
        root->left = deleteFromBst(root->left, val);
    }
    else{
        root->right = deleteFromBst(root->right, val);
    }
}

o/p -
Existing code o/p



Updated Code, This code has passed all the test cases... Please Check

int Height(Node* root){
    int x, y;
    if(root == NULL){
        return 0;
    }
    x = Height(root->left);
    y = Height(root->right);
    return x>y?x+1:y+1;
}

Node* deleteFromBst(Node* root, int val)
{
    // base case
    if(root == NULL){
        return root;
    }

    if(root->data == val){
        // 0 child
        if(root->left == NULL && root->right == NULL){
            delete root;
            return NULL;
        }

        // 2 child + 1 child
        if((root->left != NULL && root->right != NULL) || (root->left != NULL ^ root->right != NULL)){
            if(Height(root->left) > Height(root->right)){
                int maxi = maxVal(root->left)->data;    // find predecessor of root(right child of left subtree)
                root->data = maxi;    // copy the value of right most child of left subtree in root->data
                root->left = deleteFromBst(root->left, maxi);    // now delete recursively the right most child of left subtree
            }
            else
            {
                int mini = minVal(root->right)->data;          // find successor of root(left child of right subtree)
                root->data = mini;         // copy the value of left most child of right subtree in root->data
                root->right = deleteFromBst(root->right, mini);    // now delete recursively the left most child of right subtree
            }
        }

    }
    else if(root->data > val){
        root->left = deleteFromBst(root->left, val);
    }
    else{
        root->right = deleteFromBst(root->right, val);
    }
}

Deletion of 30
I/P - 30 80 40 50 -1

o/p -
Updated Code o/p

bhaiya aaj jo question tha contest me 2 wala usse mene submit kiya uski complexity n^2 dikha rha mere code ki jra aap dekhna

int minimumNet(int n, int k, vector fish)
{
vector v;
int sum=0,last=0,first=-1;
for(int i=0;i<fish.size();i++){
if(fish[i]==1){
v.push_back(i);
if(first==-1){
first=i;
}
last=i;
}
sum+=fish[i];
}
if(sum<k){
return -1;
}
else if(sum==k){
return last-first+1;
}
else{
int k1=1000;
k-=1;
for(int i=0;i<v.size();i++){
if((i+k)<v.size()){
k1=min(k1,(v[i+k]-v[i]+1));
}
}
return k1;
}

}
ye solution h uska

Adding Go Language

I wish to contribute DSA using GO Language, so is it possible to contribute here?

Remove colons (:) from folder names

Bhaiya, folders names mese colons hataa do.. checkout nahi ho raha.

error: invalid path 'Lecture 10: Solving LeetCode Arrays/arrayIntersection.cpp'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Getting error while cloning this repo

After I fork this repo and then try to clone the forked repo it giving me :Clone Succeeded but checkout failed

Error Message
Cloning into 'CodeHelp-DSA-Busted-Series'...
remote: Enumerating objects: 217, done.
remote: Counting objects: 100% (84/84), done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 217 (delta 23), reused 60 (delta 7), pack-reused 133
Receiving objects: 100% (217/217), 84.60 KiB | 656.00 KiB/s, done.
Resolving deltas: 100% (43/43), done.
error: invalid path 'Lecture 10: Solving LeetCode Arrays/arrayIntersection.cpp'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Because of this any folder except the root one.

Regarding python contribution

I have opened a pull request for recursion day1 module in python. I have added the last question's answer in python but I haven't got any response yet while other requests are getting merged. Please take a look at my pull request(#160)

Lect.22 Array String (Leetcode Question)

Video Timestamp - 55:15
Leetcode Question No- 151. Reverse Words in a String.

Bhaiya Ur Telling Reverse String But There Some Certain Condition have a look....

Here The My Solved Problem Code ..

class Solution {
public:
string reverseWords(string s) {
string ans;
stack stk;
int i = 0;
while(i < s.size()) {
string temp;
while(i < s.size() && s[i] == ' ') ++i;
while(i < s.size() && s[i] != ' ') {
temp.push_back(s[i++]);
}
if(temp.size() > 0)
stk.push(temp);
}
int j=0;
while(!stk.empty()) {
ans += stk.top(); stk.pop();
if(!stk.empty()) ans += ' ';
}
return ans;
}
};

REGARDING CONTRIBUTIONS MADE IN PYTHON

I justed wanted to know, why where the contributions made for python language of this repository are not getting merged ? Any specific reasons behind that like code quality or something ?

Please kindly look into PRs 113 and 106 .

Thank you !

Lec 10 Solving leet code arrays

Please add the homework question code. I really can not understand how to solve them simply. And the disscussion page has hasp map solutions only, Please help I'm stuck there

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.