Closed GaganMishra305 closed 11 months ago
Hey @beforeIkillYou , Explain me about the PR you have made and provide some screenshots. Explain the code clearly about the PR you have made.
@beforeIkillYou, make the PR description more clear by specifying the exact changes you have made and explaining why you made those particular changes. Additionally, clarify whether these changes resolve the issue, or if there are alternative approaches that you considered.
Okay @Illuminati9 @akhilender-bongirwar @shishiro26 @PavanaSakethaRam this is my approach. for the given problem i have found the missing number in the given array by using hashing. I have gone through the entire array and saved the frequency of its elements by using a hash and then I have returned the first element with hash value (frequency = 0).
Step 1 Implementation of hash.
Step 2 Finding and returning the first missing element that is the first element with hash value of 0 and if no number is missing from range 1 to length of array then we return -1.
Step 3 Finally we print the first missing number and if its -1 then we print that no number is missing from the given range.
Hope this clears my line of approach.
Hey @PavanaSakethaRam @akhilender-bongirwar , sorry for the misinterpretation of the problem on my part. Here i have fixed the bugs with the following procedure-
Bugs in original code- It is not able to perform its operation when there is repetition of numbers within the array and it also returns the same number if there is repetition on last element or if there is no repetition at all. The main bug is due to the presumption that elements of an sorted array will be in coherence with the indices and the first non coherent element is the missing one. This presumption gets shattered when there is repetition of elements.
So in order to resolve the issue of not being able to handle repetition of number I have used an unordered set to keep track of existing numbers and in a case where there is repetition and the whole remaining array gets offsetted by the number of repeated occurences it can look up to the elements there are and then decide if the given index is off a missing element or not. My code uses an ordered set to resolve the aforementioned issue.
Solved the missing_numbers in fix_bugs #16