Skip to content

Complete Hashing-2 assignment - #2193

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

Complete Hashing-2 assignment#2193
tejbharath wants to merge 1 commit into
super30admin:masterfrom
tejbharath:master

Conversation

@tejbharath

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Subarray Sum Equals K (SubArraySumEqualsK.java)

[Constructive feedback for the student]

VERDICT: PASS


Contiguous Array (ContiguousArray.java)

Strengths:

  1. Your solution correctly implements the running sum + HashMap approach, which is the optimal solution for this problem.
  2. Good defensive programming with the null/empty array check.
  3. Clear comments explaining the approach and complexity.
  4. The code is well-organized and readable.

Areas for Improvement:

  1. The if (rSum == 0) check is redundant. When rSum == 0, the map already contains 0 (with value -1), so the existing logic max = Math.max(max, i - map.get(rSum)) would compute i - (-1) = i + 1, which is the same result. You can remove this redundant check for cleaner code.
  2. Consider adding a brief comment explaining why map.put(0, -1) is needed (to handle subarrays starting from index 0).

Overall, your solution is correct and efficient. The minor redundancy doesn't affect correctness or performance significantly.

VERDICT: PASS


Longest Palindrome (LongestPalindrome.java)

The student has done an excellent job solving this problem. Their solution is correct, efficient, and well-documented. The approach matches the reference solution exactly, using a HashSet to track characters with odd counts. The added input validation for null/empty strings and single-character strings is a good defensive programming practice, even though the problem constraints guarantee s.length >= 1.

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