1996. The Number of Weak Characters in the Game

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

Tech Adora by Nivedita

Tech Adora by Nivedita

Жыл бұрын

PROBLEM LINK : leetcode.com/problems/the-num...
SOLUTION LINK : github.com/niveditaprity/Leet...

Пікірлер: 42
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Please do comment , like share and subscribe!! Your one click is my motivation 😁
@ashishkumaryadav5252
@ashishkumaryadav5252 Жыл бұрын
Exceptional content, best explanation on youtube.
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Glad you think so!
@gitanjalikumari9262
@gitanjalikumari9262 Жыл бұрын
Di u just explained so well...plz uploading such video😘
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Thank you 😊 Keep learning
@chandrakantkhannade7326
@chandrakantkhannade7326 Жыл бұрын
Really liked your efforts,Bhot effective thha
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Thank you 😊
@triposat
@triposat Жыл бұрын
Good Explanation!
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Glad you think so!
@085-vaibhavgusain9
@085-vaibhavgusain9 Жыл бұрын
understood your logic but having trouble implementing it in java. thank u for the help with the java code last time
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Okay i will add java code too on github
@indra16
@indra16 Жыл бұрын
subscribed 😃
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Thank you
@chandlerbing8164
@chandlerbing8164 4 ай бұрын
for drawing Do you use mouse or graphic tablet ?
@devtorch
@devtorch Жыл бұрын
hello @nivedita, thanks for the video, the explanation was quite clear. appreciate your efforts.
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Welcome :) , please recommend my channel to your friends
@rockyraj9571
@rockyraj9571 Жыл бұрын
Great Explanation...!
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Thank you :)
@narolavarshil6067
@narolavarshil6067 Жыл бұрын
Actually sorting descending for attack and if same attack then sort in ascending defence and then keeping track of maximum defence uptill current index is more intuitive.. Just a thought
@Mr_SSK
@Mr_SSK Жыл бұрын
You are doing great! Keep going...
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Thank you :)
@sparshverma9814
@sparshverma9814 Жыл бұрын
What is time complexity of this code!🥰🥰
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Nlogn
@sparshverma9814
@sparshverma9814 Жыл бұрын
@@techadorabynivedita Thank you Mam, for such quick and immediate response❤
@mr.naresh3004
@mr.naresh3004 Жыл бұрын
thanks ma'am..
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Most welcome 😊
@mrityunjoybarman9098
@mrityunjoybarman9098 Жыл бұрын
I am not getting the point why sorting in desending of defense?
@techadorabynivedita
@techadorabynivedita Жыл бұрын
Properties are sorted based on attack first in asceding order When attack levels are same then defense in descending We will start from last beacuse we know last one has highest attack level so any other attack level in left side will be either equal or less Whenever attack level will same Ex [1,9] [1,5] then we also know that left side character will greater level of defense so we wont consider it.
@raimasoni3013
@raimasoni3013 Жыл бұрын
I have started watching your videos, the concepts are quite clear and it helping me a lot in building logic. thankyou so much and keep going...!!❤
@techadorabynivedita
@techadorabynivedita Жыл бұрын
You are most welcome:),glad it helped you ,keep learning
@dipanshmalhotra564
@dipanshmalhotra564 Жыл бұрын
didi aapko pta kaise chla ki loop ulta lagana h like kind of greedy problem??
@techadorabynivedita
@techadorabynivedita Жыл бұрын
ye already pta tha ki characters ko compare krne hoge right fir km se km comparison me ho jaye iske sort and back se start krna hoga , start se v kr skte fir sorting different way me krna hoga
@dipanshmalhotra564
@dipanshmalhotra564 Жыл бұрын
@@techadorabynivedita op didi nice thank you didi for explaination ;)
@dipanshmalhotra564
@dipanshmalhotra564 Жыл бұрын
and monotonic h function toh hm yaha binary search ka use bhi kr kste h na?
@techadorabynivedita
@techadorabynivedita Жыл бұрын
han binary search use kr skte but dono me same TC o(nlogn) hoga but ye easy lga mujhe
@moviespartner5393
@moviespartner5393 Жыл бұрын
hi I followed the same approach but got TLE 😔😔 can anyone let me know what I have done wrong. class Solution { public: static bool comp(vector a,vector b) { if(a[0]!=b[0]) return a[0]b[1]; } int numberOfWeakCharacters(vector& properties) { int n=properties.size(); int count=0; sort(properties.begin(),properties.end(),comp); int def=properties[n-1][1]; for(int i=n-2;i>=0;i--) { if(properties[i][1]
@shivamrai229
@shivamrai229 Жыл бұрын
class Solution { public: static bool comp(vector &a,vector &b) { if(a[0]!=b[0]) return a[0]b[1]; } int numberOfWeakCharacters(vector& properties) { int n=properties.size(); int count=0; sort(properties.begin(),properties.end(),comp); int def=properties[n-1][1]; for(int i=n-2;i>=0;i--) { if(properties[i][1]
@rakshithr1453
@rakshithr1453 Жыл бұрын
in comp function pass it by reference static bool comp(vector &a,vector &b)
@thegreekgoat98
@thegreekgoat98 Жыл бұрын
Why are you not comparing the attack value while traversing from backwards? I think the following code is perfect: class Solution { public: bool static cmp(vector&a,vector&b) { if(a[0]==b[0]) return a[1]>b[1]; return a[0]=0;i--) { if(prop[i][1]>maxdef) maxdef=prop[i][1]; if(prop[i][0]>maxatt) maxatt=prop[i][0]; if(prop[i][1]
@techadorabynivedita
@techadorabynivedita Жыл бұрын
No need to compare because properties are sorted based on attack in ascending order and when they are equal then defence in desc order if we start from last we are sure that left side value will either equal or smaller than current one and when attack will be equal then defence level will be greater than current one
@neelam5170
@neelam5170 Жыл бұрын
when the input is:[[1,5],[1,9],[2,4]],the answer must be 0,but ur code gives 1...coz u may have equal item[0] values for the items with items[1] being higher.
@techadorabynivedita
@techadorabynivedita Жыл бұрын
It will give zero because after sorting [1,9] [1,5] [2,4] Now look at my code and compare you will get zero
188. Best Time to Buy and Sell Stock IV
24:56
Tech Adora by Nivedita
Рет қаралды 488
ОБЯЗАТЕЛЬНО СОВЕРШАЙТЕ ДОБРО!❤❤❤
00:45
Schoolboy - Часть 2
00:12
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 7 МЛН
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 860 М.
Remove K digits | Build lowest number | Leetcode #402
15:30
Techdose
Рет қаралды 88 М.
Top 50 Most Asked JavaScript Logical Interview Questions || Must Watch🤯😱
1:09:02
But what are Hamming codes? The origin of error correction
20:05
3Blue1Brown
Рет қаралды 2,3 МЛН
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 343 М.
202. Happy Number || Top Interview 150 || Leetcode
7:08
Tech Adora by Nivedita
Рет қаралды 335
ОБЯЗАТЕЛЬНО СОВЕРШАЙТЕ ДОБРО!❤❤❤
00:45