Skip to content

Add Array-2 solutions#1877

Open
nikhylw wants to merge 1 commit into
super30admin:masterfrom
nikhylw:master
Open

Add Array-2 solutions#1877
nikhylw wants to merge 1 commit into
super30admin:masterfrom
nikhylw:master

Conversation

@nikhylw
Copy link
Copy Markdown

@nikhylw nikhylw commented Jun 1, 2026

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Disappeared Numbers (disappeared_no.py)

Strengths:

  • Excellent use of the in-place marking technique to achieve O(n) time complexity
  • Proper handling of potential negative indices using abs()
  • Clean, readable code structure
  • Correctly follows the follow-up requirement of O(1) extra space

Areas for Improvement:

  • The space complexity comment "O(h)" is unclear. Since h is undefined, it should be O(1) to indicate constant extra space
  • Consider adding a brief comment explaining the marking strategy for future readers

VERDICT: PASS


max and min (game_of_life.py)

Strengths:

  • The Game of Life solution is well-structured and follows best practices
  • Good use of in-place modification with encoding to avoid extra space
  • Clean helper function for counting neighbors
  • Proper boundary handling

Critical Issue:

  • The submitted solution solves a completely different problem (Game of Life) than the one asked (max and min)
  • This appears to be a case of submitting code for the wrong problem

Recommendation:

  • Please ensure you submit code that addresses the specific problem statement
  • For the max/min problem, you would need to implement an algorithm that finds both minimum and maximum values in an array efficiently (less than 2*(N-2) comparisons)
  • The classic approach is to compare elements in pairs and maintain separate min/max variables

VERDICT: NEEDS_IMPROVEMENT


Life Game

Strengths:

  • Correct implementation of the in-place algorithm using intermediate states
  • Clean separation of the marking phase and conversion phase
  • Good use of a helper function for neighbor counting
  • Proper boundary checking for neighbor cells
  • Correctly considers dying cells (2) as alive when counting neighbors

Areas for Improvement:

  • Time complexity analysis is incorrect - should be O(mn), not O(m+n). The nested loops over all cells with 8 neighbor checks per cell results in O(mn) complexity.
  • The directions list could be defined as a class/instance variable to avoid recreation on each method call (minor optimization).

VERDICT: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants