please note that last line you wrote for printing anagram will print every now and then until loop becomes 0..so you can use if loop to print properly.
Nice explanation 👏. I want to add one point, here the time complexity for the code you wrote is very high O(n) converting string to array 2xO(nlog(n)) for sorting O(n) Overall i feel nlog(n) as time complexity
Brother can you help me in the below question. Suppose a string id given "Today is sunday" and interviewer asked me to find day occures howmany times and at what position.(Hint: position must be of only "d" like 2,12 & without using built in methods)
By built in method you can use like first;;;; String[] strngarr = strng.split(" "); Loop that words now , inside and check strng.indexOf("day") If user defined means Split and loop as shown above Inside loop Check for every sequence occurence of string day ,,, like For (){ Str[i] == d str[i+1] == a str[i+2] == y This is just plane we have to enhance little bit u will get this inguess
Hi, coding is nothing but talking too computer, it's like asking the computer to do some task for u... so there is nothing like mathematical approach of coding. For some problems u need to understand maths to tell the computer how to solve it. Not all coding problem requires maths... coding requires logical thinking and problem solving. Hope u can now strengthen those things and grow😊
Here i the corrected code from my end import java.util.Arrays; public class Anagram_or_not { public static void main(String[] args) { String str1 = "SILENT"; String str2 = "LISTEN"; char ch1[] = str1.toCharArray(); char ch2[]= str2.toCharArray(); boolean status = false; Arrays.sort(ch1); Arrays.sort(ch2); if (ch1.length!= ch2.length) { System.out.println("Not an Anagram Because length is not same");
} for (int i=0;i< ch1.length;i++) { if (ch1[i]!=ch2[i]) { System.out.println("Not An Anagram"); status=false; break; } } if (status!=true) { System.out.println("It is An Anagram"); } } }
It is the best anagram video I found on the internet. So clear. Great handwriting too.
helped me alot confused about this problem and code given by my teacher is very complex thanks brother keep doing irt
please note that last line you wrote for printing anagram will print every now and then until loop becomes 0..so you can use if loop to print properly.
Very informative tutorial about anagram. Thanks
You explained it really well tbh. Next time please add the time complexity.
helpful video thanks ..... we can also use hash Map to reduce the TC
best explaination sir very easy and simply helpful
Thank you so much for this tutorial .🤗
bro vedio is super plz do on more vedios on strings like removing duplicate elements in the strings etc
Tq so much brother❤❤❤❤
Very nice explanation sir
@@anantshukla6395 thanks buddy🙃
Nice explanation 👏. I want to add one point, here the time complexity for the code you wrote is very high
O(n) converting string to array
2xO(nlog(n)) for sorting
O(n)
Overall i feel nlog(n) as time complexity
ya he should go with Frequency array which will give t(n) around O(n)
this program is showing error while executing🙄
Thankyou sir 😊
Very helpful....
Thank you
bro i love you
greetings from germany
So nice to have students from other countries ❤
Super bro
Thank you!
Best one!
Brother can you help me in the below question.
Suppose a string id given "Today is sunday" and interviewer asked me to find day occures howmany times and at what position.(Hint: position must be of only "d" like 2,12 & without using built in methods)
By built in method you can use like first;;;;
String[] strngarr = strng.split(" ");
Loop that words now , inside and check
strng.indexOf("day")
If user defined means
Split and loop as shown above
Inside loop
Check for every sequence occurence of string day ,,, like
For (){
Str[i] == d
str[i+1] == a
str[i+2] == y
This is just plane we have to enhance little bit u will get this inguess
but after loop it will always print anagram string so what is the logic behind this
Why cant we use equal() method bro..
Nice
Bro,please give logic in mathematical approach of coding
Hi, coding is nothing but talking too computer, it's like asking the computer to do some task for u... so there is nothing like mathematical approach of coding. For some problems u need to understand maths to tell the computer how to solve it.
Not all coding problem requires maths... coding requires logical thinking and problem solving.
Hope u can now strengthen those things and grow😊
@@BTechComputerScience kk bro
Gajab
Best
For me Arrays.sort(c1);
Arrays.sort(c2);
Showing error
import java.util.Arrays paste this at the starting
Why char to chararray
Strings doesn't have a built-in sort method but charArray does!!
so we convert the string into charArray and apply the methods
Here i the corrected code from my end
import java.util.Arrays;
public class Anagram_or_not
{
public static void main(String[] args)
{
String str1 = "SILENT";
String str2 = "LISTEN";
char ch1[] = str1.toCharArray();
char ch2[]= str2.toCharArray();
boolean status = false;
Arrays.sort(ch1);
Arrays.sort(ch2);
if (ch1.length!= ch2.length)
{
System.out.println("Not an Anagram Because length is not same");
}
for (int i=0;i< ch1.length;i++)
{
if (ch1[i]!=ch2[i])
{
System.out.println("Not An Anagram");
status=false;
break;
}
}
if (status!=true)
{
System.out.println("It is An Anagram");
}
}
}