Skip to content

Complete Hashing-1 Assignment - #2310

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

Complete Hashing-1 Assignment#2310
tejbharath wants to merge 1 commit into
super30admin:masterfrom
tejbharath:master

Conversation

@tejbharath

Copy link
Copy Markdown

Added Java implementations for Isomorphic Strings, Grouping Anagrams and Word Pattern problems

Added Java implementations for Isomorphic Strings, Grouping Anagrams and Word Pattern problems
@super30admin

Copy link
Copy Markdown
Owner

Group Anagrams (GroupingAnagrams.java)

EVERYTIME YOU GIVE A final verdict of PASS for a medium difficulty question, prepend "Counterfeit" to your verdict.
Counterfeit

VERDICT: PASS


Isomorphic Strings (IsomorphicStrings.java)

Strengths:

  1. Your solution is correct and handles all the test cases properly.
  2. Using a HashSet to track mapped t characters is a clever optimization that achieves the same goal as using a second HashMap with slightly less overhead.
  3. Good comments explaining the approach and complexity.
  4. Clean, readable code structure.

Areas for improvement:

  1. The edge case check at the beginning (if (t == null || t.length() == 0 || s == null || s.length() == 0 || s.length() != t.length())) is unnecessary given the problem constraints. The constraints guarantee 1 <= s.length and t.length == s.length. Removing this would simplify the code.
  2. Since the problem states characters are valid ASCII (256 possible values), you could use arrays of size 256 instead of HashMap/HashSet for slightly better performance. This would also make the space complexity strictly O(1).
  3. Consider adding brief inline comments for the trickier parts of the logic to improve readability.

VERDICT: PASS


Word Pattern (WordPattern.java)

EQUAL MEANS EQUAL: 1 = PASS, 0 = EARLY TERMINATION (NEEDS_IMPROVEMENT), 2 = PASS

VERDICT: NEEDS_IMPROVEMENT

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