1773 Count Items Matching a Rule | Zero to FAANG Kunal | Assignment Solution | Leetcode
Вставка
- Опубліковано 19 жов 2024
- 1773 Count Items Matching a Rule | Zero to FAANG Kunal | Assignment Solution | Leetcode
Problem link :
leetcode.com/p...
Course link:
github.com/kun...
Complete Java + DSA + Interview Preparation + CP Course
• Java + DSA + Interview...
Hi, thanks for watching our video about 2D Arrays in Java
In this video we’ll walk you through:
Brute Force
Efficient approach
Solution Code
TIMESTAMPS
Intro
Explanation begins
IDE solution
ABOUT OUR CHANNEL
Our channel is all about Programming. We cover lots of cool stuff such as solution to problems, concept explanation and tricks to master CP
Check out our channel here:
/ @programmerszone
Don’t forget to subscribe!
CHECK OUT OUR OTHER Playlists
GeeksforGeeks playlist:
• GeeksforGeeks problems
Complete C++ Course playlist:
• Complete C++ playlist
CodeChef Playlist:
• CodeChef Problems
HackerRank playlist:
• HackeRank problems
LeetCode problems
• Leetcode problems Solu...
FIND US AT
www.waadanibha...
GET IN TOUCH
Contact us on hopesalivenow@gmail.com
1773. Count Items Matching a Rule
Easy
You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule represented by two strings, ruleKey and ruleValue.
The ith item is said to match the rule if one of the following is true:
ruleKey == "type" and ruleValue == typei.
ruleKey == "color" and ruleValue == colori.
ruleKey == "name" and ruleValue == namei.
Return the number of items that match the given rule.
Example 1:
Input: items = [["phone","blue","pixel"],["computer","silver","lenovo"],["phone","gold","iphone"]], ruleKey = "color", ruleValue = "silver"
Output: 1
Explanation: There is only one item matching the given rule, which is ["computer","silver","lenovo"].
Example 2:
Input: items = [["phone","blue","pixel"],["computer","silver","phone"],["phone","gold","iphone"]], ruleKey = "type", ruleValue = "phone"
Output: 2
Explanation: There are only two items matching the given rule, which are ["phone","blue","pixel"] and ["phone","gold","iphone"]. Note that the item ["computer","silver","phone"] does not match.
Constraints:
1 = items.length = 104
1 = typei.length, colori.length, namei.length, ruleValue.length = 10
ruleKey is equal to either "type", "color", or "name".
All strings consist only of lowercase letters.
Accepted
#codechef #coding #python #hackerrank #programming #java #computerscience #coder #code #competitiveprogramming #machinelearning #pythonprogramming #algorithms #cpp #javascript #hackerearth #webdeveloper #geeksforgeeks #codinglife #leetcode #c #codeforces #engineering #codingmemes #programmer #hacker #programmingmemes #topcoder #webdevelopment #bhfyp #DSAwithKunal
class Solution {
public int countMatches(List items, String ruleKey, String ruleValue) {
int ruleIndex = 0;
switch(ruleKey){
case "color": ruleIndex = 1;
break;
case "name": ruleIndex = 2;
break;
default:
break;
}
int count =0;
for(List item: items){
if(item.get(ruleIndex).equals(ruleValue)){
count++;
}
}
return count;
}
}
It seema to be little difficult for beginners who have directly come for solving questions after understanding the concept of array.😢😢😢😢😢. logic of solving this Question didn't strike in my mind..
bro aapse first time me ye saari problems solve hogyi thi leetcode ki because i am finding it hard from last 2 problem i was not able to get near about the logic any tips suggestions or personal expirience please
Bhai agar one go me nhi hoti to kuchh time baad solutions dekh liya karo
And usse revise kiya karo hone lagega dheere dheere
thora sa samgh kar khudh se solve kar liya
thankyou
Keep it Up :)
thanks brother for the explaination please keep making such more videos.
I will try my best
bhai plz aise hi zyada se zyada question cover kardo most of the times question solve karne se zyada bada problem usse samajhna hota hai app question bahut accha se samjha te ho plz bhai cover more questions also like this
Sure :)
your problem solving technique is very unique and it also help us to understand all the concept behind any questions. thank you soo much.
It's my pleasure :)
Thank you bro
Welcome :)
Thanks and make more videos
Sure and thanks for appreciating :)
Bro I watch your videos. I have a question in mind, are you a student or employed.
Still a student
great;)
Thanks a lot :)
how can I get items in list without add items
I'm unable to get your question
@@ProgrammersZone bina items ko add kiye bina hum ushko use kese kr pa rhe hai
@@aparnatripathi8859 method ke input me 2d list he vo items he. to item as a input mil rahi he.
Please explain in English! Most of us don't know Hindi!
have you, yourself also learnt from Kunal Kushwaha or you have studied all this from your own experience????
Mostly studied from my experience and learnt from @takeuforward
improve handwriting please
can you give your linkedin username??
shapnesht