- 405
- 245 591
CODE KAR LO
India
Приєднався 17 січ 2017
Hii Everyone, Here you will be getting out the videos related to Data Structures and Algorithms and the Video's will be completely in Hindi, So keep watching and keep coding 👍👍
Maximum Difference | Stack | GFG POTD | C++ | Java | Code Kar Lo
Given an integer array arr of integers, the task is to find the maximum absolute difference between the nearest left smaller element and the nearest right smaller element of every element in array arr. If for any component of the arr, the nearest smaller element doesn't exist then consider it as 0.
0:00 Introduction
0:11 Problem Statement
1:47 Explanation
7:09 C++ Code
11:13 Java Code
My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html
How to Earn By GFG Articles:- ua-cam.com/video/XjvEgkd49Gk/v-deo.html
Infosys Coding Questions:- ua-cam.com/play/PLq3GlRZI14HuZlfpLmVY915bolizB8O2-.html
Pattern Playlist: ua-cam.com/play/PLq3GlRZI14HsyjTmtjkBMlZCq8bZUUaP3.html&si=IHO0d35RRoAR0RYq
Problem Link:-www.geeksforgeeks.org/problems/maximum-difference-1587115620/1
Code Link:-github.com/ShubhamKashyap138/Data-Structure/blob/main/Maximum%20Difference
Playlist Link:-ua-cam.com/play/PLq3GlRZI14Hui2ILGsfF1Uf2RnbNu9wT3.html&si=UGRWpHbM8Q2w4TTQ
Linkedin:- www.linkedin.com/in/shubham-kashyap-65a29a218/
Instagram:- im_shubham_kashyap?igshid=YmMyMTA2M2Y=
My GFG Profile:- auth.geeksforgeeks.org/user/shubhamrajput6156/practice
gfg potd
gfg potd today
gfg problem of the day
potd gfg
potd
potd today
gfg
#dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming
0:00 Introduction
0:11 Problem Statement
1:47 Explanation
7:09 C++ Code
11:13 Java Code
My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html
How to Earn By GFG Articles:- ua-cam.com/video/XjvEgkd49Gk/v-deo.html
Infosys Coding Questions:- ua-cam.com/play/PLq3GlRZI14HuZlfpLmVY915bolizB8O2-.html
Pattern Playlist: ua-cam.com/play/PLq3GlRZI14HsyjTmtjkBMlZCq8bZUUaP3.html&si=IHO0d35RRoAR0RYq
Problem Link:-www.geeksforgeeks.org/problems/maximum-difference-1587115620/1
Code Link:-github.com/ShubhamKashyap138/Data-Structure/blob/main/Maximum%20Difference
Playlist Link:-ua-cam.com/play/PLq3GlRZI14Hui2ILGsfF1Uf2RnbNu9wT3.html&si=UGRWpHbM8Q2w4TTQ
Linkedin:- www.linkedin.com/in/shubham-kashyap-65a29a218/
Instagram:- im_shubham_kashyap?igshid=YmMyMTA2M2Y=
My GFG Profile:- auth.geeksforgeeks.org/user/shubhamrajput6156/practice
gfg potd
gfg potd today
gfg problem of the day
potd gfg
potd
potd today
gfg
#dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming
Переглядів: 177
Відео
Wildcard Pattern Matching | Dynamic Programming | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 6332 години тому
Given two strings pattern and str which may be of different size, You have to return 1 if the wildcard pattern i.e. pattern, matches with str else return 0. All characters of the string str and pattern always belong to the Alphanumeric characters. The wildcard pattern can include the characters ? and * ‘?’ - matches any single character. ‘*’ - Matches any sequence of characters (including the e...
Number of Pairs | Binary Search | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 2,3 тис.4 години тому
Given two positive integer arrays arr and brr, find the number of pairs such that xy greater than yx (raised to power of) where x is an element from arr and y is an element from brr. 0:00 Introduction 0:11 Problem Statement 1:02 Explanation 11:16 C Code 17:17 Java Code My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html How to Earn By GFG Articles:- ua-cam.com/video/XjvEgkd49Gk/v-deo.html ...
0 - 1 Knapsack Problem | Dynamic Programming | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 6497 годин тому
You are given weights and values of items, and put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that we have only one quantity of each item. In other words, given two integer arrays val and wt which represent values and weights associated with items respectively. Also given an integer W which represents knapsack capacity, find out the maximum sum ...
Left View of Binary Tree | Binary Tree | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 2579 годин тому
Given a Binary Tree, return Left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from Left side. The task is to complete the function leftView(), which accepts root of the tree as argument. If no left view is possible, return an empty tree. 0:00 Introduction 0:23 Problem Statement 1:00 Explanation 5:04 C Code 7:25 Java Code My DSA Journey:- ua-cam.com/video/q...
Kth Smallest | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 42919 годин тому
Given an array arr[] and an integer k where k is smaller than the size of the array, the task is to find the kth smallest element in the given array. It is given that all array elements are distinct. Follow up: Don't solve it using the inbuilt sort function. 0:00 Introduction 0:13 Problem Statement 1:48 Explanation 4:53 C Code 6:48 Java Code My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.h...
Split an Array into Two Equal Sum Subarrays | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 35121 годину тому
Given an array of integers arr, return true if it is possible to split it in two subarrays (without reordering the elements), such that the sum of the two subarrays are equal. If it is not possible then return false. 0:00 Introduction 0:11 Problem Statement 0:53 Explanation 2:51 C Code 3:51 Java Code My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html How to Earn By GFG Articles:- ua-cam.c...
Product Array Puzzle | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 264День тому
Given an array nums[], construct a Product Array nums[] such that nums[i] is equal to the product of all the elements of nums except nums[i]. 0:00 Introduction 0:11 Problem Statement 0:48 Explanation 4:49 C Code 7:30 Java Code My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html How to Earn By GFG Articles:- ua-cam.com/video/XjvEgkd49Gk/v-deo.html Infosys Coding Questions:- ua-cam.com/play/...
Maximize The Cut Segments | Dynamic Programming | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 367День тому
Given an integer n denoting the Length of a line segment. You need to cut the line segment in such a way that the cut length of a line segment each time is either x , y or z. Here x, y, and z are integers. After performing all the cut operations, your total number of cut segments must be maximum. Return the maximum number of cut segments possible. Note: if no segment can be cut then return 0. 0...
Add 1 to a Linked List Number | Linked List | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 478День тому
You are given a linked list where each element in the list is a node and have an integer data. You need to add 1 to the number formed by concatinating all the list node numbers together and return the head of the modified linked list. Note: The head represents the first element of the given array. 0:00 Introduction 0:11 Problem Statement 1:03 Explanation 5:39 C Code 10:03 Java Code My DSA Journ...
Square Root of a Number | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 27414 днів тому
Given an integer n, find the square root of n. If n is not a perfect square, then return the floor value. Floor value of any number is the greatest Integer which is less than or equal to that number 0:00 Introduction 0:06 Problem Statement 1:18 Explanation 4:29 C Code 5:54 Java Code My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html How to Earn By GFG Articles:- ua-cam.com/video/XjvEgkd49...
Median of Two Sorted Arrays | Array | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 1,1 тис.14 днів тому
Given 2 sorted integer arrays arr1 and arr2. Find the median of two sorted arrays arr1 and arr2. 0:00 Introduction 0:18 Problem Statement 1:31 Explanation 11:51 C Code 19:16 Java Code My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html How to Earn By GFG Articles:- ua-cam.com/video/XjvEgkd49Gk/v-deo.html Infosys Coding Questions:- ua-cam.com/play/PLq3GlRZI14HuZlfpLmVY915bolizB8O2-.html Pat...
Pattern 8 | K Pattern | Pattern | C++ | Code Kar Lo
Переглядів 1914 днів тому
My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html How to Earn By GFG Articles:- ua-cam.com/video/XjvEgkd49Gk/v-deo.html Infosys Coding Questions:- ua-cam.com/play/PLq3GlRZI14HuZlfpLmVY915bolizB8O2-.html Code Link:-github.com/ShubhamKashyap138/Patterns/blob/main/K Pattern Task5 Code:- github.com/ShubhamKashyap138/Patterns/blob/main/Task5 GFG Potd Playlist Link:-ua-cam.com/play/PLq3GlRZI14...
Validate an IP Address | String | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 82421 день тому
You are given a string str in the form of an IPv4 Address. Your task is to validate an IPv4 Address, if it is valid return true otherwise return false. IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots, e.g., 172.16.254.1 0:00 Introduction 0:12 Problem Statement 1:35 Explanation 4:58 C Code 1...
Bottom View of Binary Tree | Binary Tree | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 46321 день тому
Given a binary tree, return an array where elements represent the bottom view of the binary tree from left to right. 0:00 Introduction 0:10 Problem Statement 1:55 Explanation 7:39 C Code 11:15 Java Code My DSA Journey:- ua-cam.com/video/quZBBv12mCQ/v-deo.html How to Earn By GFG Articles:- ua-cam.com/video/XjvEgkd49Gk/v-deo.html Infosys Coding Questions:- ua-cam.com/play/PLq3GlRZI14HuZlfpLmVY915...
N Meetings in One Room | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 67721 день тому
N Meetings in One Room | GFG POTD | C | Java | Code Kar Lo
Pattern 7 | Hollow Triangle Pattern | Pattern | C++ | Code Kar Lo
Переглядів 3921 день тому
Pattern 7 | Hollow Triangle Pattern | Pattern | C | Code Kar Lo
The Celebrity Problem | Matrix | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 57221 день тому
The Celebrity Problem | Matrix | GFG POTD | C | Java | Code Kar Lo
Edit Distance | String | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 1,1 тис.21 день тому
Edit Distance | String | GFG POTD | C | Java | Code Kar Lo
Spirally Traversing a Matrix | Matrix | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 41521 день тому
Spirally Traversing a Matrix | Matrix | GFG POTD | C | Java | Code Kar Lo
Longest Common Prefix of Strings | String | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 67221 день тому
Longest Common Prefix of Strings | String | GFG POTD | C | Java | Code Kar Lo
Rat in a Maze Problem - I | Recursion | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 46128 днів тому
Rat in a Maze Problem - I | Recursion | GFG POTD | C | Java | Code Kar Lo
Row With Max 1s | Matrix | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 32128 днів тому
Row With Max 1s | Matrix | GFG POTD | C | Java | Code Kar Lo
Remove Duplicates | String | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 41028 днів тому
Remove Duplicates | String | GFG POTD | C | Java | Code Kar Lo
Merge Two BST 's | Binary Search Tree | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 474Місяць тому
Merge Two BST 's | Binary Search Tree | GFG POTD | C | Java | Code Kar Lo
Largest BST | Binary Tree | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 678Місяць тому
Largest BST | Binary Tree | GFG POTD | C | Java | Code Kar Lo
Pattern 6 | Butterfly Star Pattern | Pattern | C++ | Code Kar Lo
Переглядів 41Місяць тому
Pattern 6 | Butterfly Star Pattern | Pattern | C | Code Kar Lo
Maximum Product Subset of an Array | Array | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 670Місяць тому
Maximum Product Subset of an Array | Array | GFG POTD | C | Java | Code Kar Lo
Pattern 5 | Diamond Start Pattern | Pattern | C++ | Code Kar Lo
Переглядів 152Місяць тому
Pattern 5 | Diamond Start Pattern | Pattern | C | Code Kar Lo
Remove Half Nodes | Binary Tree | GFG POTD | C++ | Java | Code Kar Lo
Переглядів 370Місяць тому
Remove Half Nodes | Binary Tree | GFG POTD | C | Java | Code Kar Lo
Good Explanation
Thanks 🙏❤️
❤❤❤❤❤
Giving TLE
Please check the code from code link
you used to have a different theme, why you changed it ? and how did u got it in the first place?
Just using dark theme for eyes protection. I did not get your second question
Great Explanation..Thanks
Thanks 🙏❤️
very messy writing and very messy explanation 😩
Very nice explanation👍
Thanks 🙏❤️
Pyhon code: class Solution: def countPairs(self,arr,brr): def findGreaterElements(key): low, high = 0, len(brr)-1 while low <= high: mid = (low+high)//2 if brr[mid] > key: high = mid-1 else: low = mid+1 return len(brr) - high - 1 # we need to no of elements greater # than x in brr effeciently. brr.sort() cnt = 0 one, two, threeFour = brr.count(1), brr.count(2), brr.count(3)+brr.count(4) for x in arr: # with x==1, no pair can be formed, ever. if x == 1: continue # exception: for x=2 and y=3 or 4, pairs cannot be formed if x == 2: cnt -= threeFour # exception: for x=3, y=2 can form a pair if x == 3: cnt += two # for any x and y=1, pairs can be formed cnt += one # every number greater than x can form a pair cnt += findGreaterElements(x) return cnt
How do we come up with these exceptions while in an interview?
By taking different examples and running your code and after getting wrong answer you can dry run that.
Apki consistency 🔥🔥
Thanks 🙏❤️
bhai do you have any update about 30dayspotd challenge?
Ager apko koi update mile, please also share with me.
No brother
@@NutanGupta-r6e ok
set is better suited for this, is there any performance impact on using maps instead of set ? I guess no since SC would be same
Yes but i am bised towards map 😅
Hello Sir, we can do the same problem in O(N), using Quickselect Algorithm, Thanks for the great explanation.
No brother it totally depend on the type of test case. Worst case for qucik select can be N^2. Thanks
@@code_kar_lo Ya, that's true, worst case time complexity goes N^2.
I have one doubt why we are traversing array index from i=1 instead of i=0 in the last loop, since array indexing always start from 0..please clear..
Yes but in the given array we do not have any zeros as par the constraints that is why we are traversing from 1.
Arrays.sort(arr) Return k-1
k<=0 , is the better condition, it's fine here as gfg has given unique elements..
Yes that is why i have compared it with 0 only.
Hello bhaiyya, I've solved this problem using the max-heap. int kthSmallest(vector<int> &arr, int k) { // code here priority_queue<int> pq; for(int i=0;i<arr.size();i++){ pq.push(arr[i]); if(pq.size()>k) pq.pop(); } return pq.top(); } Its T.C = O(n) and S.C = O(1) and, Thank you bhaiiyaa..
Brother max heap itself takes time and space. Time complexity for this will be O(NlogK) and space will be O(K)
@@code_kar_lo Oh acha, samjha ab... thank you for the guidance bhaiyya
Thanks for Guiding me through your video , I always watch your video even i solve question myself . As, Always there is a new thing to learn from your video
Thanks a lot 🙏❤️
nycc .. just a suggestion try to explain gfg/ leetcode contest solutions . ur views will also go up . THANKYOU
Thanks. I have time issues otherwise i can upload leetcode as well
best approach i have seen! thanks for this
Thanks a lot 🙏❤️
Thank you bhaiyya
NIT patna ❤
Check ex: n=7, x=2,y=4,z=5 Why can't we cut 7 3 times with x?? Why the ans here is 2 , by using x and z ?? Wrong problem
If you cut n with x for 3 times then segment length will be 2,2,2,1. But it is mentioned that all segment length should be from x,y,z. Problem is not wrong you made a mistake in understanding it.
nice explanation 👍
Thanks 🙏❤️
If me break kyu Kara..?
Jese hi 1 add ho jata hai usse aage traverse krni ki jarurat nhi
@@code_kar_lo thanks
Bhai ek int variable me value store karane se solve kyu nhi ho rha..?
Because length of the linked list jyada ho sakti hai or phir vo int me store nhi hogi
@@code_kar_lo toh long long int se kar sakte?
Nhi vo bhi nhi kar payega store
Khudse solve kiya, and Thank you bhaiiya
Great 🙌. Keep it up.
Best Explanation in the entire youtube....Thanks bhaiya
Thanks 🙏❤️
double ans = Math.sqrt((double)num); return (long)ans; I liked your approach as well. Helpful for interviews when they ask to solve without inbuilt methods.
Thanks 🙏❤️
ajka potd hata diya kya?
Already posted tha. Check community.
Well Explained
Thanks
public boolean isValid(String str) { String[] arrOfStr = str.split("\\."); if(arrOfStr.length != 4){ return false; } for(int i=0;i<arrOfStr.length;i++){ if(arrOfStr[i].equals("")){ return false; } if((arrOfStr[i].length() > 1) && (arrOfStr[i].charAt(0)) == '0' ){ return false; } int x=Integer.parseInt(arrOfStr[i]); if(x <= 255 ){ continue; }else{ return false; } } return true; what is problem with this
sahi hai bhai, mera bhi same logic hi tha bs andr int val = Integer.parseInt(arr[i]); if(val<0 || val>255){ return false; } ye inner loop m code tha sare tc pass kr gye
Sir What a Beautiful Explanation
Thanks 🙏❤️
if (str[index + 1] == '0' && i - index - 1 > 1) return false; if (str[index + 1] == '0' && str.length() - index - 1 > 1) return false; for checking leading zeros at start and end
i solved on my own, but they changed test cases, did few modifications now , working fine idk why they do this... btw we can use regex to solve these type of problem also.... I will try that later... and ye technically TC bhi O(1) hua an since str length is 15 max....
Hn string ki length bohat jyada nhi hogi
well and informative explain vaiya💖
Thanks a lot 🙏❤️
Solved on my own, Thank you bhaiyya
Keep it up 🙌
@@code_kar_lo yes thank you bhaiya
First time I am facing this problem I submitted a wrong code which passed all tc After watching ur video I realized that I did a small wrong for which code should not run And surprisingly now i am trying to submit the old code which was accepted it is showing Rte 😅
Sometimes GFG changes the test cases. I also faced the same problems a few times.
@@AMANKUMAR-bt6cw achha
Yes gfg changes the test cases.
Can we solve it using recurrsion.. ? if yes . what would be its T.C ?? Thank you bhaiyya
It is easy to solve it using iterative as our goal is to go to the last node present at a level at last. But in recusive way you can come to the last node first so you have to do some more adjustment to achieve it. Time and space will be same.
@@code_kar_lo Okay understood, thank you bhaiyya
Aaj wala khud se bana lia bhai...Nice explaination!!! class Solution { //Function to return a list containing the bottom view of the given tree. public ArrayList <Integer> bottomView(Node root){ // Code here SortedMap<Integer, Integer> map = new TreeMap<>(); Queue<Pair> q = new LinkedList<>(); q.add(new Pair(root, 0)); while(!q.isEmpty()){ Pair p = q.poll(); Node currNode = p.node; int currLevel = p.level; if(currNode.left != null) q.add(new Pair(currNode.left, currLevel-1)); if(currNode.right != null) q.add(new Pair(currNode.right, currLevel+1)); map.put(currLevel, currNode.data); } ArrayList<Integer> ans = new ArrayList<>(); for(Map.Entry<Integer, Integer> entry:map.entrySet()){ ans.add(entry.getValue()); } return ans; } } class Pair{ Node node; int level; Pair(Node node, int level){ this.node = node; this.level = level; } }
Thanks. Keep learning. 🙌🙏
Understood, Thank you bhaiiya
Today I solved this problem myself, thank u bhaiyya
Great, Keep it up 🙌🔥
Really Informative Bhaiya !!!!!
Thanks 🙏❤️
Easily understood, thank you bhaiyya
Thanks 🙏❤️
very neat and clean explanation bhaiya
Thanks 🙏❤️