Check Two Strings are Anagram Or Not using Sort and Equals in Java

  Рет қаралды 24,551

Naveen AutomationLabs

Naveen AutomationLabs

2 жыл бұрын

In this video, I have explained How to Check Two Strings Are Anagram Or Not using Sort and Equals in Java.
~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
kzbin.info%20Au...
Follow me on my Facebook Page:
/ naveenqtpexpert
Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
t.me/joinchat/Q8HTanc9Xi4os0tS
Naveen AutomationLabs Paid Courses:
Java & Selenium:
naveenautomationlabs.com/manua...
Java & API +POSTMAN + RestAssured + HttpClient:
naveenautomationlabs.com/selen...

Пікірлер: 23
@vinitp4559
@vinitp4559 2 жыл бұрын
Wonderful Naveen thanks alot.👍 Can you pls share link of many such tricky interview questions
@onlyforautomation6450
@onlyforautomation6450 2 жыл бұрын
Thanks... nice 👍🏻
@sandeepkokane9549
@sandeepkokane9549 2 жыл бұрын
Thanks Naveen
@kapilsingh1385
@kapilsingh1385 Жыл бұрын
Hi naveen, can we compare texts from two different web application using selenium. If yes please help Thansk
@user-tb7uv4xn4i
@user-tb7uv4xn4i Жыл бұрын
Extremly Good!😁
@pandudamera7211
@pandudamera7211 2 жыл бұрын
Thanks brother
@ashwinib5017
@ashwinib5017 2 жыл бұрын
Thanks Naveen....got this question in Oracle interview today. I had given the above solution only, was asked if one of the string is Null how will he handle write the code, and interviewer asked me for other ways also like Hashmap couldn't answer that :(
@swathiu6742
@swathiu6742 Жыл бұрын
Hi Naveen , This solution is really helped me to understand . But how to identify the aranagrams in the given list of words example { car ,arc, , ate,eat , cat etc . Could you please provide the solutions for this ?
@MrAnkit812
@MrAnkit812 Жыл бұрын
Sir , Why we are doing sorting here , can't we reverse both the string and then check , whether two strings are Anagram or not?
@vengateshm2122
@vengateshm2122 2 жыл бұрын
Are noob, boon anagrams? Can it contain duplicate characters?
@karishmakhan2621
@karishmakhan2621 5 ай бұрын
public static void main(String[] args) { String s1 ="Listen"; String s2 = "silent"; s1 = s1.toLowerCase(); s2= s2.toLowerCase(); if(s1.length()== s2.length()) { char[] charArray1 = s1.toCharArray(); char[] charArray2 = s2.toCharArray(); Arrays.sort(charArray1); Arrays.sort(charArray2); boolean result = Arrays.equals(charArray1, charArray2); if(result==true) { System.out.println(s1 + " and " + s2 +" are anagram"); } else { System.out.println(s1 + " and " + s2 +" are not anagram"); } } else { System.out.println(s1 + " and " + s2 +" are not anagram, length are not same "); } }
@hemanthkumar240
@hemanthkumar240 2 жыл бұрын
Need more such amazing imp interview questions. Sir please make a vedio on imp java interview questions
@pratikbhowmik
@pratikbhowmik 2 жыл бұрын
Hey he already has many go check it out
@hemanthkumar240
@hemanthkumar240 2 жыл бұрын
@@pratikbhowmik okay got it thanks
@souvikchatterjee7400
@souvikchatterjee7400 2 жыл бұрын
Hi Naveen, I have an upcoming interview for a project in my company. We had a call with the project manager and he mentioned that if you use Arrays.sort() or any other internal sorting method, they reject the solution. In such cases like the one you mentioned, it gives optimised solution? What are your views on this?
@DeepakLalchandaniProfile
@DeepakLalchandaniProfile 2 жыл бұрын
Yes, we are not supposed to use Arrays.sort() method
@alinabehera2152
@alinabehera2152 2 жыл бұрын
Yes, In most of the interviews they do not accept the Sort() method if the question is related to only sorting an array but in this type of questions it should be Ok to answer this.
@namitgupta352
@namitgupta352 2 жыл бұрын
Thanks for a different approach in this video. I always learn something new from u. Another approach using array mapping: public class Solution { public static void main(String[] args) { System.out.println(check_anagrams("listen", "SILEN T")); } public static boolean check_anagrams(String s1, String s2) { s1 = s1.replaceAll("\\s", ""); s2 = s2.replaceAll("\\s", ""); if (s1.length() != s2.length()) return false; s1 = s1.toLowerCase(); s2 = s2.toLowerCase(); int[] abcd = new int[26]; for (int i = 0; i < s1.length(); i++) { abcd[(int) s1.charAt(i) - 97]++; } for (int i = 0; i < s2.length(); i++) { int c = (int) s2.charAt(i) - 97; if (abcd[c] > 0) { abcd[c]--; } else { return false; } } return true; } }
@felixrajan4804
@felixrajan4804 2 жыл бұрын
Hi Naveen. Your videos are awesome. Telegram link has expired. Share the new link.
@naveenautomationlabs
@naveenautomationlabs 2 жыл бұрын
t.me/joinchat/9FrG-KzGlvxjNmQ1
@DeepakLalchandaniProfile
@DeepakLalchandaniProfile 2 жыл бұрын
Can you upload the Java code for all KZbin tutorials to Github?
@naveenautomationlabs
@naveenautomationlabs 2 жыл бұрын
github.com/naveenanimation20/JavaTopics2021.git
@bihari1422
@bihari1422 Жыл бұрын
public class Anagram { public static void main(String[] args) { // TODO Auto-generated method stub String a1 = "triangle"; String a2 = "intergal"; int count = 0; if (a1.length() == a2.length()) { for (int i = 0; i < a1.length(); i++) { for (int j = 0; j < a2.length(); j++) { char x = a1.charAt(i); char y = a2.charAt(j); if (a1.charAt(i) == a2.charAt(j)) { count++; break; } } } if (count == a1.length()) { System.out.println("Yes anagram"); } else { System.out.println("Not anagram only same length and count is " + count); } } else { System.out.println("Length not matching to be anagram "); } } }
Check Two Strings are Anagram Or Not using StringBuilder in Java
15:58
Naveen AutomationLabs
Рет қаралды 7 М.
Must-have gadget for every toilet! 🤩 #gadget
00:27
GiGaZoom
Рет қаралды 11 МЛН
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
00:37
SMOL German
Рет қаралды 20 МЛН
WHO DO I LOVE MOST?
00:22
dednahype
Рет қаралды 78 МЛН
Check Two Strings are Anagrams or Not - Java Code
15:26
Programming Tutorials
Рет қаралды 15 М.
HackerRank Java - Java Anagrams Solution Explained
11:00
Nick White
Рет қаралды 36 М.
Frequently Asked Java Program 10: Generate Fibonacci series
9:50
Check if two strings are anagrams
8:50
Techdose
Рет қаралды 68 М.
Java Program to check given String is Panagram or not?
8:24
Learn With KrishnaSandeep
Рет қаралды 56 М.
How to check Two Strings are Anagram in Java | Coding Skills
15:52
Coding Skills
Рет қаралды 14 М.
LeetCode 242. Valid Anagram Solution Explained - Java
6:23
Nick White
Рет қаралды 44 М.
После ввода кода - протирайте панель
0:18
Собери ПК и Получи 10,000₽
1:00
build monsters
Рет қаралды 1,9 МЛН