No video

Word Pattern | LeetCode problem 290

  Рет қаралды 5,963

Technosage

Technosage

Күн бұрын

Word Pattern
Leetcode problem number 290
Solution in JAVA
JAVA interview programming playlist:
• Interview Programming ...
Linkedin: / amrita-bala-a2b79460
#java #interviewquestions #leetcode

Пікірлер: 20
@sathiroy4788
@sathiroy4788 Жыл бұрын
It's logic is almost same that's you already discussed in Isomorphic String problem. Again Thanks a lot.
@TechnosageLearning
@TechnosageLearning Жыл бұрын
Yeah..If you learn the logics ...you can solve multiple problems with one logic..
@imtiyazali5894
@imtiyazali5894 7 ай бұрын
This code finally accept all case in leetcode for this question:=> public boolean wordPattern(String pattern, String s) { HashMap hm = new HashMap(); Set set = new HashSet(); String arr[] = s.split(" "); if(pattern.length() != arr.length){ return false; } for(int i=0; i
@sathiroy4788
@sathiroy4788 Жыл бұрын
Thanks for this beautiful explanation.
@raadali3270
@raadali3270 Жыл бұрын
Thank you so much mam Great explanation 👍👍👍
@user-jq2qu6dj9f
@user-jq2qu6dj9f 6 ай бұрын
Its not working for "abba" And "dog dog dog dog"
@user-fo3fi1td3j
@user-fo3fi1td3j 2 ай бұрын
Yes this test case failed
@user-fo3fi1td3j
@user-fo3fi1td3j 2 ай бұрын
class Solution { public boolean wordPattern(String pattern, String s) { Map map=new HashMap(); String[] arr=s.split(" "); if(pattern.length()!=arr.length) { return false; } for(int i=0; i
@roqyaquran241
@roqyaquran241 Жыл бұрын
Sometimes you have to zoom out to see the whole code, or put it in github it's even better. Thanks anyway
@TechnosageLearning
@TechnosageLearning Жыл бұрын
Sure I will start putting codes to github
@a.kgaming2360
@a.kgaming2360 3 ай бұрын
I was about to point it out cuz the regex is given according to the spaces but then saw this comment.
@mdniyazhashmi458
@mdniyazhashmi458 Жыл бұрын
Hello Amrita, I am getting only "false" as output trying the same code. package org.leeetcode.problems; import java.util.HashMap; import java.util.Map; public class WordPattern { public static void main(String[] args) { String pattern="abba"; String str="cat, dog, dog, cat"; System.out.println(isWordPattern(pattern,str)); } private static boolean isWordPattern(String pattern, String s) { String []str= s.split(" "); Map hm = new HashMap(); if(pattern.length()!= str.length) { return false; } for(int i=0;i
@TechnosageLearning
@TechnosageLearning Жыл бұрын
Hi Sorry my mistake.. The input String is " cat dog dog cat" If you give this input ,it will work...( since we are splitting the string with whitespaces) Or else you need to change the regex, if you want the same input string String[] arr = s.split( ", ") Thanks for pointing out ! Will edit and upload the video again ! Please try and let me know if that works!
@mdniyazhashmi458
@mdniyazhashmi458 Жыл бұрын
@@TechnosageLearning it works thanks!!!
@TechnosageLearning
@TechnosageLearning Жыл бұрын
Added the disclaimer in the video..Thanks again for pointing it out
@Future_software_enginneer
@Future_software_enginneer 3 ай бұрын
how can i become a good software engineer to writing a code
@naveenbarnwal7923
@naveenbarnwal7923 Жыл бұрын
i am getting error in this code
@TechnosageLearning
@TechnosageLearning Жыл бұрын
Take the code from git repo i shared and then give it a try
@ramineninagajaswanth6476
@ramineninagajaswanth6476 Жыл бұрын
hello hi i did it using the same method which u taught in isomorphic strings but it is giving wrong answer would you pls check class Solution { public boolean wordPattern(String pattern, String s) { if(pattern.length()!=s.length()) return false; HashMapl=new HashMap(); s=s.trim(); String a[]=s.split(" "); for(int i=0;i
@nibinvarghese5736
@nibinvarghese5736 3 ай бұрын
You should check the pattern length with String array length instead of just original String length you should replace this : f(pattern.length()!=s.length()) return false; with this : if(pattern.length()!=a.length) return false;
Valid Palindrome | LeetCode problem 125
5:43
Technosage
Рет қаралды 15 М.
LeetCode 290. Word Pattern Solution Explained - Java
8:58
Nick White
Рет қаралды 14 М.
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 4,5 МЛН
WILL IT BURST?
00:31
Natan por Aí
Рет қаралды 40 МЛН
1ОШБ Да Вінчі навчання
00:14
AIRSOFT BALAN
Рет қаралды 4,6 МЛН
Longest Common Prefix | LeetCode problem 14
5:42
Technosage
Рет қаралды 30 М.
290. Word Pattern || Java || Leetcode || Hindi
15:59
Coding Sphere
Рет қаралды 1,6 М.
Valid Anagram | LeetCode problem 242
8:33
Technosage
Рет қаралды 15 М.
Reverse words in a string | Leetcode problem 151
6:08
Technosage
Рет қаралды 36 М.
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 4,5 МЛН