Skip to content

Completed Hashing-2#2187

Open
Praniksha123 wants to merge 2 commits into
super30admin:masterfrom
Praniksha123:master
Open

Completed Hashing-2#2187
Praniksha123 wants to merge 2 commits into
super30admin:masterfrom
Praniksha123:master

Conversation

@Praniksha123

Copy link
Copy Markdown

Implemented solutions for all Hashing-2 problems.

@super30admin

Copy link
Copy Markdown
Owner

Subarray Sum Equals K (Sample.java)

Strengths:

  1. All three solutions are correct and produce the expected output
  2. Good understanding of the prefix sum technique for Problems 1 and 2
  3. Clean code structure with appropriate variable naming
  4. Efficient use of HashMap/HashSet for O(1) lookups
  5. Good handling of edge cases (initializing map with base values)

Areas for Improvement:

  1. For Problem 1, the code can be simplified using map.getOrDefault() like the reference solution, which is more concise
  2. Consider adding more detailed comments explaining the logic step-by-step
  3. The code could benefit from better formatting consistency (some spacing inconsistencies)

Minor Optimizations:

  • In Problem 1, the if-else block for updating the map can be replaced with a single map.put(rsum, map.getOrDefault(rsum, 0) + 1) line for better readability

VERDICT: PASS


Contiguous Binary Subarray

Strengths:

  1. The solution correctly implements the prefix sum approach for finding contiguous subarrays with equal 0s and 1s
  2. Code is well-documented with clear comments explaining the algorithm
  3. Variable naming is clear and descriptive
  4. The optimization of storing only the first occurrence is correctly implemented
  5. The base case initialization (map.put(0,-1)) is correct, handling subarrays starting from index 0

Areas for Improvement:

  1. Consider adding early return for edge cases like empty or single-element arrays for better robustness
  2. The variable name maxi could be more descriptive as maxLength for better readability

Note: The student also submitted solutions for two other problems (subarraySum and longestPalindrome), which shows good initiative, though only the Contiguous Binary Subarray solution was requested.

VERDICT: PASS


Longest Palindrome in a string

Strengths:

  1. The solution correctly solves the problem with proper logic
  2. Clean, readable code with meaningful variable names
  3. Efficient use of HashSet for tracking odd-frequency characters
  4. Correctly handles the center character case when odd frequencies exist

Areas for Improvement:

  1. The file contains solutions for three different problems, but only one was requested. For future submissions, focus on the specific problem asked.
  2. Consider adding comments to explain the algorithm logic for better maintainability
  3. The HashSet could be renamed to unpairedChars or oddChars to better reflect its purpose
  4. Minor: The code structure is good, but ensure complete class declarations in future submissions

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