#24 Swapping pairs make sum equal | Data Structures and Algorithms Interview question | Hashing #2
ฝัง
- เผยแพร่เมื่อ 26 ส.ค. 2024
- In this video, we will see how to solve the above question, which is asked in many company interviews.
Data Structures and Algorithms Interview question playlist:
• Data Structures and Al...
You can practise those questions from here: practice.geeks...
And if this link doesn't work just google "question_name gfg practice".
Also if you have any doubts, pls mention them in the comment box.
But bhaiya here in expected space complexity is constant but you have used map
Good Uday, that you noticed that point.
HINT
It can be done in O(1) space, sort both the array and give it a try.
Some IMP info:
See Interviewer will not ask you specifically to do it in O(nlogn+mlogm).
So if you give him even better approach, for ex O(n). Then little increase in space complexity can be accepted.
So you should be free to play with time and space complexity as per the interviewer requirement.
didnt understood the corner case
Corner case referring to odd number.
If we divide odd number by 2 then it would come in decimal, causing invalid case.
So we are taking it to be even number.
Tanisha let me know if further clarification is needed?
great approach bhaiya , amazing , bhaiya can i get your linkedi n to connect ?