Hello Jee,
This repo is for the students for easy access to all the programs taught under Codehelp's DSA Busted Series.
Youtube Channel: CodeHelp - by Babbar
Your Instructor: Love Babbar
Learn a Lot, Enjoy a Lot.
This repo is creating providing students easy access to all the programs taught under Codehelp's 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.
Youtube Channel: CodeHelp - by Babbar
Your Instructor: Love Babbar
Learn a Lot, Enjoy a Lot.
please bhaiya do this
Requesting developer access
bhaiya rat in a maze wala code link nhi hai so please if possible give that
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 .
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;
}
}
I wish to contribute DSA using Python Language, So is it possible to contribute here?
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;
}
};
I would like to provide the code for Lecture 61 homework question: Interleave The First Half Of The Queue With The Second Half
I like your way of solving questions but when I am stuck in the logic building of HW questions then I search on the internet I found different solutions which contrast my current logic.
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);
}
}
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
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
For question 2(Lowest Common Ancestor in a Binary Tree ), for the 1st test case(11:15) showed in the lecture (i/p: 5 4 3 7 8 22 27 N N 12 9 29 N) it is returning segmentation fault.
I wish to contribute DSA using GO Language, so is it possible to contribute here?
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 :/'
i tried same code on my vscode but it wasnt working
it worked on online compilers
any idea how this is happening?
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.
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)
Please refer https://github.com/loveBabbar/CodeHelp-DSA-Busted-Series/blob/main/Lecture020%20ArrayQuestions/mergeSortedArray1.cpp
line no 25 is incorrect
//copy kardo second array k remaining element ko
while(j<m) {
arr2[k++] = arr2[j++];
}
It should be arr3[k++] = arr2[j++];
Bhaiya aapka course bahut acha hai lekin mujhe homework questions notes mein milte hai to samaj nahi aate isliye please notes and questions separately pdf bana kar provide kardo please.
Thank you bhaiya.๐๐๐๐๐๐
Please update code after lecture 65 it will be helpfull
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;
}
};
Lecture no. - 81 based on trie (Phone Dictionary)
bhaiya please update codes of lecture 40
The else part is incomplete
else{
curr1=next1;
next1=next1->next;
if(next==NULL){
curr1->next=curr2;
return first;
}
}
homework done
Love Babbar Interleave queue.zip
ehomework donehomework done
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 !
some minor changes :
arr2[k++] = arr2[j++]; instead of this
ar3[k++] = arr2[j++];
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
please upload codes from lecture 65 onwards
bhaiya please update the code
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.