If someone had skills like you especially the way you teach, they would launch this course as a paid one. Let it be anyone in this world. But you're here trying to help students like me and I'm very grateful. Thanks a ton, Kunal!
Brother you are legend Several videos I have seen but I never understood these concepts You made these thing so easy Thanks Brother for such a beautiful and lovely content Concepts are fully cleared With the help of these videos now I have the faith and confidence to crack good companies Thanks Brother once again Great going Keep it up and deliver content like these
@@KunalKushwaha at 1:16:50 we should not sort the array as it will rearrange the array and subsets will be wrong. And we know in subset : 2, 1, 2 is the subset of 2, 1, 2 but 1, 2, 2 is not subset of 2, 1, 2
Hello Kunal. I want to know, After the DSA course, will you show us how to use our skills in open source and all that stuffs till how to approach in a company? If not then please consider this.🙏🙏🙏
Q9 : Sub sequences of a string with duplicate elements This last question can be solved in a shorter way like this: public static ArrayList subsequenceIterativeDuplicate(int[] arr) { ArrayList outerList = new ArrayList(); outerList.add(new ArrayList()); for(int num : arr) { int outerListSize = outerList.size(); for(int i=0;i
I dreaded recursion subset problem for almost an year now, and I stopped practicing because I was not very good with recursion. Now I can re-begin and work my way to FAANG
I have seen so many videos related to java but no use after watching your videos Iam understanding concepts clearly Thankyou so much for helping those students who are not able to afford paid courses
Guys don't take any minute word coming from his mouths lightly what he speaks comes from his experience so what i suggest watch video one time solve some questions come again and you will grasp things more efficiently
In the last question we can simply do that question as the previous question but after that just check whether each element is present in the list if it is there just remove duplicates from the list which takes O(N) time complexity. But brother you are sorting the array which takes O(NLog N) which is not effecient as compared to removing the duplicates after doing this question as the previous question.
Q9 : Subsequences of a string with duplicate elements Can be solved in easier way with the code snippet mentioned below:- ------------------------------------------------------ List outerList = new ArrayList();//outerList outerList.add(new ArrayList()); for (int num : arr) { int size = outerList.size(); for (int i = 0; i < size; i++) { List internalList = new ArrayList(outerList.get(i)); internalList.add(num); if (!outerList.contains(internalList)) { outerList.add(internalList); } } } return outerList; ---------------------------------------------------------
No one taught me recursion like you. I, like many others like me, initially thought I understood recursion completely after watching the Fibonacci and Factorial examples. But then the reality hit when I tried to solve some medium-level problems. I realized that my concepts are so hazy that I had no clue how to apply anything I learnt in logically writing code to solve a problem. This site not only taught me the concept, but it is also so thorough that it forced me see what is happening from different angles and write code in multiple ways. Thanks, Kunal, for making recursion as clear as algebra instead of it being some monster like vector calculus or something. You are so thorough. Awesome.
Kunal, I cannot believe this is so easy. I wrapped my head around with backtracking a lot and was still confused. Even took sessions of a paid educational website to understand backtracking. And literally I just watched your video once and all concepts are clear. You are legend.
How is subset question's time complexity O(N 2^N). Even though the outer loop runs n times, the inner loop is not always O(2^N). You end up running a total of (2^0 + 2^1 + .. 2^(N-1)) = 2^N commands. The time complexity should therefore be O(2^N).
This is such a great video and it's incredible that you are not charging for sharing this immense knowledge. Just love the way you first explain the approach ,how to think and then actually solve the problem.Thankyou so much for these videos . And please please upload the graph and trees series 🙌
for the last question instead of adding the start or end index , if found duplicate just start the inner loop with outerarray size / 2 and it works fine #include
Kisi ko time complexity smj aai ? to smja do please Loop I guess 2^(N-1) time chalega har element ko process krte time, fir yaha complexity 2^N kyu hai
I have a question...subset of array should be in the same order right so if we sort the array then it's subsets won't be in the same order as the original array given to us.
I have a doubt in subsets introducation is empty set also a subset of set [2.5,9] as i had learnt earlier in cpp in my previous data structure long back that time i didnt knew recursion is a topic and you not mentioned.
In ques 9 we can just check if outer list contains that subset. If it doesn't contain, then only we should add it in outer. This way we'll avoid duplicates: public static List subsetDuplicates(int[] arr) { List outer = new ArrayList(); outer.add(new ArrayList()); for(int num: arr) { int n= outer.size(); for (int i = 0; i < n; i++) { List inner=new ArrayList(outer.get(i)); inner.add(num); if(!outer.contains(inner)) outer.add(inner); } } return outer; }
@Kunal Kushwaha , the solution in Q9 changes the order of the original array. Wouldn't the result be considered as a list of subsets and not a list of subsequences?
for qn 9, please find my recursive solution below approach: if we ignore the occuring of duplicates char means we ignore each of that duplicate char public class Recursion{ public static void main(String[] args) { System.out.println(subSetsWithDupInString("122", "")); } static ArrayList subSetsWithDupInString(String str, String ans){ if(str.isEmpty()){ ArrayList ls = new ArrayList(); ls.add(ans); return ls; } char ch = str.charAt(0); ArrayList left = new ArrayList(); ArrayList right = new ArrayList();
this part from subseqAscii shows error in c++ vectorright =check_str(p+(ch+0),up.substr(1)); it works well on java but not on c++ if anyone can explain please
Bhaiya i am getting admsion into DTU CS can u please make a video 1st year roadmap I was waiting to get into college to start programming with ur course Loving ur confidence and content
ruclips.net/p/PLPX75d4curILdTmhcM5iJ6ReNx-LKW12P here, these are old videos of kunal when he used to work with a ed-tech, he has made a complete 4 year roadmap for B.Tech students
I thought to take half of outer list size as start index, but sooner realize what if multiple duplicate elements are coming, it will fail to survive that condition
Amazing!!!! You proved that a good teacher is not one who tells all the solutions but someone we can lead us to all solutions. As once I listen to you logic coding has become damn easy!!
Actually finding the subset with duplicates using iteration is easy then what kunal tried to code ..you need to just check whether the outer array contains the ans we have obtained and if yes then dont add the ans to the outer array My Code is: import java.util.ArrayList; import java.util.List; public class subsetsusingrecursoncopy { public static void main(String[] args) { int [] arr={1,2,2}; List ans=iteration(arr); System.out.println(ans); } static List iteration(int [] arr) { ArrayList inner=new ArrayList(); List outer=new ArrayList(); outer.add(inner); for(int n:arr) { int a=outer.size(); for(int i=0;i
although this is easier to code and think about, it adds a O(n) order time for each subset. and since there are 2^n subsets, it adds a total of O(n * 2^n) operations to the algo. it doesn't change the final complexity but for real world applications this might be a significant difference. something to consider.
After all that your efforts and following all the previous playlist videos , Now i get some confidence in DSA to solve problems easily . Thanks Kunal bhaiyaa (Sir) for all that quality Content that i hunt for all over youtube
Nice video kunal. For the last question we can add a check before adding the inner list to the outer list, If the outer list already contains the inner list or not
how is it "How simple was it"? I am dying to understand the recurssion trree,it literally took me 2hrs to understand the so called simple subsequences..... it hurts
public class Main { public static void main(String[] args) { System.out.println("Hello world!"); String s="aaaaaaaababababbbaaaaaa"; System.out.println(fun(s,0,new StringBuilder())); } static String fun (String s,int i,StringBuilder a) { if(i==s.length()) return a.toString(); if(s.charAt(i)!='a') { a.append(s.charAt(i)); } return fun(s,i+1,a); } } use stringbuilder it is more efficient that srting class
Everytime you make me like your video no matter what I don't know anyone who explains every small things like you I love that you made this beautiful course for free even though it's so much worth. May krishna bless you !
Dont want to print space in substring :-[abc, ab, ac, a, bc, b, c, ] output should [abc, ab, ac, a, bc, b, c] ============== public static ArrayList SubStringArrayList (String p, String up,ArrayList list) { if(up.isEmpty()) { //System.out.println(p); list.add(p); return list; } char ch=up.charAt(0); //Add String in UnProcessed SubStringArrayList(p+ch,up.substring(1),list); //Return Processed/ SubStringArrayList(p,up.substring(1),list); return list; } please Help on this @Kunal
Broo tnq very much ❤❤❤ you are helping me a lot for learning recursion. since in these topic i am very confused.However i see your videos ❤ it's like a wow.
171. Excel Sheet Column Number class Solution { public int titleToNumber(String columnTitle) { int ans = 0; return helper(columnTitle, ans); } static int helper(String columnTitle, int ans){ if(columnTitle.isEmpty()){ return ans; }
Hey kunal in last question u told that complexity will be same as previous..but u sorted the array so i think nlogn should be multiplied with previous time complexity. Am i true.. please clarify
00:03 String Questions and Subsequences 03:35 Recursion subset and subsequence concepts 10:19 Explanation of function call and process in string operations. 13:46 Recursion and string processing explained 21:02 Understanding recursion and string questions 24:31 Subset, subsequence, and string questions are important for interview preparation. 31:26 Understanding recursion and subset/sequence problems. 34:43 Recursion and string questions in a RUclips video 40:49 Discussion on various functions and activities using code 44:06 Recursion and string questions are challenging. 51:15 The video discusses creating subsequence and string questions. 54:30 Sequencing, string manipulation, and recursion in programming 1:01:07 Explaining recursion and its use in solving problems 1:04:05 Creating a new list based on the original list size. 1:10:16 Understanding subsets and complexities 1:13:16 Preventing duplicate elements in newly created subjects
DSA + interview preparation playlist: ruclips.net/p/PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ
If someone had skills like you especially the way you teach, they would launch this course as a paid one. Let it be anyone in this world. But you're here trying to help students like me and I'm very grateful. Thanks a ton, Kunal!
Dont give him ideas!
difficult to understand iterative and duplicate problems :(
😢😢
Brother you are legend
Several videos I have seen but I never understood these concepts
You made these thing so easy
Thanks Brother for such a beautiful and lovely content
Concepts are fully cleared
With the help of these videos now I have the faith and confidence to crack good companies
Thanks Brother once again
Great going
Keep it up and deliver content like these
Thank You 🙏
@@KunalKushwaha at 1:16:50 we should not sort the array as it will rearrange the array and subsets will be wrong.
And we know in subset : 2, 1, 2 is the subset of 2, 1, 2 but 1, 2, 2 is not subset of 2, 1, 2
@@gouravsyal2052 yep bro
2,1,2 is subset of 2,1,2
@@KunalKushwaha sir it change order of array 2,1,2 while sort it become 1,2,2 1,2,2 is not subset of (2,1,2 ) .(2,1,2) is subset of 2,1,2 1:16:08
24:55 when did he teach sliding window?
Hello Kunal. I want to know, After the DSA course, will you show us how to use our skills in open source and all that stuffs till how to approach in a company? If not then please consider this.🙏🙏🙏
Q9 : Sub sequences of a string with duplicate elements
This last question can be solved in a shorter way like this:
public static ArrayList subsequenceIterativeDuplicate(int[] arr)
{
ArrayList outerList = new ArrayList();
outerList.add(new ArrayList());
for(int num : arr)
{
int outerListSize = outerList.size();
for(int i=0;i
I also did the same thing...
I dreaded recursion subset problem for almost an year now, and I stopped practicing because I was not very good with recursion. Now I can re-begin and work my way to FAANG
me in the situation where i cant understand subset problems specially when for loop is used
@@jamtaranumber2841 you still struggling w/ iterative approach? lemme know, i can help you, can share the explanation here
@@sameerakhatoon9508 yeah can you share your discord / linkedin
Sister are u in good company now?
24:52 - 24:58 If I am not wrong, sliding window has not covered.
Don't worry he keeps track of syllabus on github issue, maybe mistakenly said that.
Bro when i see your video it gives me confidence 👍
I have seen so many videos related to java but no use after watching your videos Iam understanding concepts clearly
Thankyou so much for helping those students who are not able to afford paid courses
Guys don't take any minute word coming from his mouths lightly what he speaks comes from his experience so what i suggest watch video one time solve some questions come again and you will grasp things more efficiently
sahi hai bhai💯
Hug Diya na Last Question me nhi aayi intution smgh only for last question baki puri video bdiya h bs last question 😒❤
In the last question we can simply do that question as the previous question but after that just check whether each element is present in the list if it is there just remove duplicates from the list which takes O(N) time complexity. But brother you are sorting the array which takes O(NLog N) which is not effecient as compared to removing the duplicates after doing this question as the previous question.
Thank you so much for explaining this beautifully. When can we expected videos for DP, graphs and trees?
A new episode of recussion session 😂😂
Q9 : Subsequences of a string with duplicate elements
Can be solved in easier way with the code snippet mentioned below:-
------------------------------------------------------
List outerList = new ArrayList();//outerList
outerList.add(new ArrayList());
for (int num : arr) {
int size = outerList.size();
for (int i = 0; i < size; i++) {
List internalList = new ArrayList(outerList.get(i));
internalList.add(num);
if (!outerList.contains(internalList)) {
outerList.add(internalList);
}
}
}
return outerList;
---------------------------------------------------------
contains method takes O(n) of time then it leads to O(n^3) for overall time complexity
static List subSetDuplicates(int[] nums) {
Arrays.sort(nums);
List outerList = new ArrayList();
outerList.add(new ArrayList());
for (int i = 0 ;i < nums.length ; i++) {
int start = 0;
int end = outerList.size();
if( i > 0 && nums[i] == nums[i - 1]){
start = start + (end - start ) / 2;
}
for (int j = start; j < end; j++) {
ArrayList intenalList = new ArrayList(outerList.get(j));
intenalList.add(nums[i]);
outerList.add(intenalList);
}
}
return outerList;
}
Waa ye hi time mila tha upload karne ko 😐
No one taught me recursion like you. I, like many others like me, initially thought I understood recursion completely after watching the Fibonacci and Factorial examples. But then the reality hit when I tried to solve some medium-level problems. I realized that my concepts are so hazy that I had no clue how to apply anything I learnt in logically writing code to solve a problem. This site not only taught me the concept, but it is also so thorough that it forced me see what is happening from different angles and write code in multiple ways. Thanks, Kunal, for making recursion as clear as algebra instead of it being some monster like vector calculus or something. You are so thorough. Awesome.
First I found Difficulty in understanding the subset problem . After carefully going through I too got it .This guy is awesome
Which video has sliding window problem?
Kunal, I cannot believe this is so easy. I wrapped my head around with backtracking a lot and was still confused. Even took sessions of a paid educational website to understand backtracking. And literally I just watched your video once and all concepts are clear.
You are legend.
+1
Hii can u please tell me that is this course worth following as m a beginner no programming background plz reply confused
@@manavarora7644 Hii can u please tell me that is this course worth following as m a beginner no programming background plz reply m confused
@@rishika9102 PICK A programming language first, then learn it.
How is subset question's time complexity O(N 2^N). Even though the outer loop runs n times, the inner loop is not always O(2^N). You end up running a total of (2^0 + 2^1 + .. 2^(N-1)) = 2^N commands. The time complexity should therefore be O(2^N).
same query
we need to consider time taken to copy the inner list to outer list
Other : How to solve a problem.
Le kunal : How to approach a problem.
That was the plan
hey kunal..still u didn't upload dynamic programming, graph, trees etc.....
This is such a great video and it's incredible that you are not charging for sharing this immense knowledge.
Just love the way you first explain the approach ,how to think and then actually solve the problem.Thankyou so much for these videos .
And please please upload the graph and trees series 🙌
Fun fact: In iterating subsequence with duplicate you can set the start as outer.size() /2, thereby u dont need to use end variable itself
Not the best approach but to handle duplicates we can do this in previous code.
if(!outer.contains(internal)){
outer.add(internal);
}
for the last question instead of adding the start or end index , if found duplicate just start the inner loop with outerarray size / 2 and it works fine
#include
using namespace std;
vector subsetrec(string main,string pro){
vector s;
if(main.empty()){
s.push_back(pro);
return s;
}
char ch = main[0];
vector s1 = subsetrec(main.substr(1),pro);
vector s2 = subsetrec(main.substr(1),pro+ch);
s.insert(s.end(),s1.begin(),s1.end());
s.insert(s.end(),s2.begin(),s2.end());
return s;
}
void subsetitr(){
vector v{1,2,3,3};
vector res;
res.push_back({ });
for(int i=0;i 0 && v[i] == v[i-1]) j= (n/2); // LOOK HERE
for(;j
Can you explain your thought process behind why it works ?
@@gnanaprakashm843 he is just removing duplicates bro , that's it.
@@laxminarayanakoyyana1753 I see I'll look into it. thanks 🙏
since a set does not allow duplicates , so shldnt (2,2) , (1,2,2) be removed from final answer ?
Kisi ko time complexity smj aai ? to smja do please
Loop I guess 2^(N-1) time chalega har element ko process krte time, fir yaha complexity 2^N kyu hai
'Recursion made easy' by kunal.
Good Intuation, Thought process and superb way of teaching.
Good work 🙂
hi Kunal can you please do sliding window problems?
I have a question...subset of array should be in the same order right so if we sort the array then it's subsets won't be in the same order as the original array given to us.
This and the merge sort video are the only one I just can't get in my head.
no one explained recursion in so much detail like Kunal. Please someone give Kunal a medal already
Hi, can anyone explain me Why we use outer.get(i) at 1:08:07 .
if we are sorting the array then will it not change the ans for subset question as [1, 2, 3] has different subsets than [2, 3, 1]
I have a doubt in subsets introducation is empty set also a subset of set [2.5,9] as i had learnt earlier in cpp in my previous data structure long back that time i didnt knew recursion is a topic and you not mentioned.
In ques 9 we can just check if outer list contains that subset. If it doesn't contain, then only we should add it in outer. This way we'll avoid duplicates:
public static List subsetDuplicates(int[] arr)
{
List outer = new ArrayList();
outer.add(new ArrayList());
for(int num: arr)
{
int n= outer.size();
for (int i = 0; i < n; i++)
{
List inner=new ArrayList(outer.get(i));
inner.add(num);
if(!outer.contains(inner))
outer.add(inner);
}
}
return outer;
}
1:21:31 it will be good if we sort the array first, for the test cases like [1, 2,2,2] or [4, 4,4,1,4]. otherwise it will fail.
Great job man!
.contains will take another internal nested loop so it increases the time complexity...
@@kcalbduorp3499 yes
brother can you make videos on patterns like 2-pointer, prefix sum, merge intervals etc. Questions from these topics are a lot
Ofc
@@KunalKushwaha Is it possible for you to provide these codes in python. I am literally struck
This video took me 8 hr to get completed but it all worth it. Thank you so much ❤
Brother can you please tell me which keyboard you are using
@Kunal Kushwaha
, the solution in Q9 changes the order of the original array. Wouldn't the result be considered as a list of subsets and not a list of subsequences?
for qn 9, please find my recursive solution below
approach: if we ignore the occuring of duplicates char means we ignore each of that duplicate char
public class Recursion{
public static void main(String[] args) {
System.out.println(subSetsWithDupInString("122", ""));
}
static ArrayList subSetsWithDupInString(String str, String ans){
if(str.isEmpty()){
ArrayList ls = new ArrayList();
ls.add(ans);
return ls;
}
char ch = str.charAt(0);
ArrayList left = new ArrayList();
ArrayList right = new ArrayList();
int i = 1;
while(i
Please make a video on subarray concepts
this part from subseqAscii shows error in c++
vectorright =check_str(p+(ch+0),up.substr(1));
it works well on java but not on c++
if anyone can explain please
same problem they are not working in python
you should have been a doctor
44:21 can anyone explain the passing in the argument solution. i.e. how will u return two recursive calls simultansly, any help appreciated!
Legendary way of teaching! Thanks brother
My pleasure!
10:05
le kunal : ccd
le siri : yeah bruhh!! LOL.
Bhaiya i am getting admsion into DTU CS can u please make a video 1st year roadmap
I was waiting to get into college to start programming with ur course
Loving ur confidence and content
ruclips.net/p/PLPX75d4curILdTmhcM5iJ6ReNx-LKW12P
here, these are old videos of kunal when he used to work with a ed-tech, he has made a complete 4 year roadmap for B.Tech students
Hi Kunal, Can you please recommend a book for DSA. Similar type content as of you. Please 🙏🏻
Thanks for teaching us like no one did till now!! One small request, please make lectures on dynamic programming as well!!
I thought to take half of outer list size as start index, but sooner realize what if multiple duplicate elements are coming, it will fail to survive that condition
DP PLEASE BROOOOOO
can anybody please tell in which video kunal has covered sliding window...
you explained very well but still i am not able to code or solve the assignment problems please suggest something to overcome
From 58:26 I have doubt, I need to do it again
Bro can we just use a check of .contain() on outer for previous set in Duplicate Question ?
True, it becomes so simple there itself.
Solution:
if(!outer.contains(inner))
outer.add(inner);
@@vaibhavnagwani9686 yea and kunal solution will make it incorrect as after sorting (3,2,1); (1,2,3) ... will show same ans which is incorrect.
recursion is still hard but you explained it well
Your confidence level is what makes you different from others. The best dsa course ever!
can anybody please tell in which video kunal has covered sliding window...
@@rockrk2519 he hasn't covered yet he definitely will
Amazing!!!! You proved that a good teacher is not one who tells all the solutions but someone we can lead us to all solutions. As once I listen to you logic coding has become damn easy!!
One of most awaited vidoe
Wait kar rha tha iske liye....
Amazing content bro... Keep doing the good work..Lots of luck 🎉
bhai 24:55 sliding window? did i miss anything?
Yar last wala iteration ka logic samaj nai aya
Actually finding the subset with duplicates using iteration is easy then what kunal tried to code ..you need to just check whether the outer array contains the ans we have obtained and if yes then dont add the ans to the outer array
My Code is:
import java.util.ArrayList;
import java.util.List;
public class subsetsusingrecursoncopy {
public static void main(String[] args) {
int [] arr={1,2,2};
List ans=iteration(arr);
System.out.println(ans);
}
static List iteration(int [] arr)
{
ArrayList inner=new ArrayList();
List outer=new ArrayList();
outer.add(inner);
for(int n:arr)
{
int a=outer.size();
for(int i=0;i
although this is easier to code and think about, it adds a O(n) order time for each subset. and since there are 2^n subsets, it adds a total of O(n * 2^n) operations to the algo. it doesn't change the final complexity but for real world applications this might be a significant difference. something to consider.
I've also come with same approach.
some sliding window problems if possible please include .. Will be very helpful :)
After hashmaps
After all that your efforts and following all the previous playlist videos , Now i get some confidence in DSA to solve problems easily . Thanks Kunal bhaiyaa (Sir) for all that quality Content that i hunt for all over youtube
Nice video kunal. For the last question we can add a check before adding the inner list to the outer list, If the outer list already contains the inner list or not
Best recursion series I have watched.Excellent explanation. Thanks Kunal
You are most welcome
what will be the time and space complexity of the processed/un-processed method?
1000cr ka package wala banda, noice.
how is it "How simple was it"? I am dying to understand the recurssion trree,it literally took me 2hrs to understand the so called simple subsequences..... it hurts
Kunal can you make a sheet of qstins 200-300 for PBC companies it'll be helpful for revision as well as prepration
No, this is time waste. Follow lectures and assignments.
@@KunalKushwaha okay
phele to dur se pair chu k parNaam bro 🙏🙏 DhanSuuu lecture Kunal bhai... Nobody teaches like you.. but plz complete krdo bhai playlist... 🙏🙏
Shall i use C++ list with splice() to imitate java's arraylist used with addAll()?
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
String s="aaaaaaaababababbbaaaaaa";
System.out.println(fun(s,0,new StringBuilder()));
}
static String fun (String s,int i,StringBuilder a)
{
if(i==s.length())
return a.toString();
if(s.charAt(i)!='a')
{
a.append(s.charAt(i));
}
return fun(s,i+1,a);
}
}
use stringbuilder it is more efficient that srting class
Brother....I'm waiting for your reactjs and vanilla js course...Hope you see this comment
Bhaiii you are legend, when you are coming with OOP java tutorials
string st(string org,string ans)
{
if(org.empty() == 1)
{
return ans;
}
if(org.find("apple") == 0)
{
string temp = org;
org = "";
for(int j = 5;j
Bro this content is great. thanks for your effort
Just one question man how did you get this much knowledge
Everytime you make me like your video no matter what
I don't know anyone who explains every small things like you
I love that you made this beautiful course for free even though it's so much worth.
May krishna bless you !
removing a:
public class strrecurr {
public static void main(String[] args) {
removea("", "aabcsydufcgiueaad");
}
static void removea(String answer, String strgiven) {
if (strgiven.isEmpty()) {
System.out.println(answer);
return;
}
if (strgiven.charAt(0) == 'a') {
removea(answer, strgiven.substring(1));
} else {
answer = answer + strgiven.charAt(0);
removea(answer, strgiven.substring(1));
}
}
}
In the last question, why not track duplicates using a HashSet?
Dont want to print space in substring :-[abc, ab, ac, a, bc, b, c, ] output should [abc, ab, ac, a, bc, b, c]
==============
public static ArrayList SubStringArrayList (String p, String up,ArrayList list)
{
if(up.isEmpty())
{
//System.out.println(p);
list.add(p);
return list;
}
char ch=up.charAt(0);
//Add String in UnProcessed
SubStringArrayList(p+ch,up.substring(1),list);
//Return Processed/
SubStringArrayList(p,up.substring(1),list);
return list;
}
please Help on this @Kunal
Broo tnq very much ❤❤❤ you are helping me a lot for learning recursion. since in these topic i am very confused.However i see your videos ❤ it's like a wow.
The Goat ❤
1:10:43 how's time complexity is O(n*2^n). I think it should be O(2^n)
Sir aapke cursor ka color change karo
Can u please make video on dynamic programming also
static ArrayList subset2(String n , String ans){
ArrayList l1 = new ArrayList();
if(n.isEmpty()) {
l1.add(ans);
return l1;
}
char currentCharacter = n.charAt(0);
ArrayList ans1 = subset2(n.substring(1), ans+currentCharacter);
ArrayList ans2 = subset2(n.substring(1), ans);
l1.addAll(ans1);
l1.addAll(ans2);
return l1;
}
Skip a Character(Using StringBuilder)
static StringBuilder recursive(String st, char skip, StringBuilder sb, int index) {
if (index >= st.length()) {
return sb;
}
char ch = st.charAt(index);
if (ch != skip) {
sb.append(ch);
}
return recursive(st, skip, sb, index + 1);
}
Skip a string(Using StringBuilder)
static StringBuilder recursive(String st, String skip, StringBuilder sb, int lastIndex) {
int indexSkipStr = st.indexOf(skip, lastIndex);
if (indexSkipStr == -1) {
return sb.append(st.substring(lastIndex));
}
sb.append(st, lastIndex, indexSkipStr);
return recursive(st, skip, sb, indexSkipStr + skip.length());
}
Recursion session... Just like therapy session
171. Excel Sheet Column Number
class Solution {
public int titleToNumber(String columnTitle) {
int ans = 0;
return helper(columnTitle, ans);
}
static int helper(String columnTitle, int ans){
if(columnTitle.isEmpty()){
return ans;
}
char ch = columnTitle.charAt(0);
int charVal = ch - 'A' + 1;
return helper(columnTitle.substring(1), ans*26+charVal);
}
}
Hey kunal in last question u told that complexity will be same as previous..but u sorted the array so i think nlogn should be multiplied with previous time complexity. Am i true.. please clarify
00:03 String Questions and Subsequences
03:35 Recursion subset and subsequence concepts
10:19 Explanation of function call and process in string operations.
13:46 Recursion and string processing explained
21:02 Understanding recursion and string questions
24:31 Subset, subsequence, and string questions are important for interview preparation.
31:26 Understanding recursion and subset/sequence problems.
34:43 Recursion and string questions in a RUclips video
40:49 Discussion on various functions and activities using code
44:06 Recursion and string questions are challenging.
51:15 The video discusses creating subsequence and string questions.
54:30 Sequencing, string manipulation, and recursion in programming
1:01:07 Explaining recursion and its use in solving problems
1:04:05 Creating a new list based on the original list size.
1:10:16 Understanding subsets and complexities
1:13:16 Preventing duplicate elements in newly created subjects
U r diamond dude...May lord protect u from Aliens for the boon of mankind.