There is a slight mistake in Brute Force Approach in the video, Please refer below solution for (int i = 0 ; i < nums.length - 1; i++) { // It should go till second last element for (int j = i + 1; j < nums.length ; j++ ) { // We should check the condition with j and increment j, not i if (nums[i] == nums[j]) { return true; } } } return false; If you have a better solution, do comment. and check out the whole playlist of Leetcode questions ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-cORK0YESg9A.html
Sir, you are amazing I recently started learning DSA in java and for this question I couldn't think beyond brute-force solution, but you explained every solution in a very simplistic manner Please keep making such amazing lectures
Bhaiya agr hume element mil jaye toh return true krke break lga do hume aage again check krne ki zaroorat nhi hai. Thankyou for this .Please Never stop this leetcode series😀
thanks for your comment, one thing to note is return will work like a break statement because if the element is found, it will return the function and will not check any further.