Solution Arry-2#1865
Conversation
Disappeared Numbers (findminmax.py)It appears you have submitted a solution for a different problem (finding min and max) instead of the "Disappeared Numbers" problem. Please ensure you are solving the correct problem. For the min-max problem, your code is correct and efficient. However, for the disappeared numbers problem, you need to implement a solution that finds missing numbers in the range [1, n]. Consider using techniques like marking indices as visited by negating values or using a set for O(n) time complexity. VERDICT: NEEDS_IMPROVEMENT max and min (findmissing.py)It seems there might be a misunderstanding. The problem you were asked to solve is to find the minimum and maximum in an array with a constraint on the number of comparisons (less than 2*(N-2)). However, your solution is for a different problem: finding disappeared numbers in an array. For the min-max problem, you need to compare elements to find the smallest and largest. The reference solution uses a technique that processes elements in pairs to reduce the number of comparisons. For each pair, it first compares the two elements to each other (1 comparison), and then compares the smaller to the current min (1 comparison) and the larger to the current max (1 comparison). This leads to about 3 comparisons per 2 elements, which is better than the naive approach of 2 comparisons per element (which would be 2*(N-1) comparisons). I recommend reviewing the problem statement again and implementing the min-max solution. You can start by handling the array length (even or odd) and then processing pairs. For each pair, compare the two elements to determine the local min and max, then update the global min and max. This way, you use approximately 3*(n/2) comparisons, which is less than 2*(n-2) for n>=2. VERDICT: NEEDS_IMPROVEMENT Life Game (gameOfLife.py)Your solution is correct and efficient. Well done! You successfully implemented the in-place update with O(1) space and O(m*n) time. Here are a few suggestions for improvement:
Overall, your solution is good. Keep up the good work! VERDICT: PASS |
No description provided.