Hashing 2#2174
Conversation
Subarray Sum Equals K (SubArraySumK.java)Strengths:
Areas for Improvement:
Overall, this is an excellent solution that demonstrates a strong understanding of the prefix sum technique. VERDICT: PASS Contiguous Binary Subarray (LongestPalindrome.java)It appears that you have submitted a solution for the "Longest Palindrome" problem instead of the "Contiguous Binary Subarray" problem. Please double-check the problem you are solving and ensure you are uploading the correct file. For the "Contiguous Binary Subarray" problem, you need to use a different approach, such as using a hash map to track the running sum (where you treat 0 as -1 and 1 as +1) and look for indices where the running sum is the same, indicating an equal number of 0s and 1s in between. I recommend revisiting the problem statement and implementing the correct solution. VERDICT: NEEDS_IMPROVEMENT Longest Palindrome in a string (Solution.java)It seems there has been a mix-up in the problem you are solving. The problem you are asked to solve is about finding the length of the longest palindrome that can be built from the characters in the string. Your current solution is for a different problem (Contiguous Array). For the correct problem, the key idea is to count the frequency of each character. A palindrome can have at most one character with an odd frequency (which would be the center). The rest of the characters must have even frequencies. You can use a HashSet to keep track of pairs: when you see a character for the second time, you can remove it from the set and add 2 to the count. If there are any characters left in the set at the end, you can add 1 for the center. Here is a step-by-step approach for the correct problem:
This approach has O(n) time complexity and O(1) space complexity (since the number of distinct characters is bounded). You should also note that the problem states that letters are case-sensitive, so 'A' and 'a' are considered different. VERDICT: NEEDS_IMPROVEMENT |
No description provided.