LeetCode-Feedback / LeetCode-Feedback

669 stars 328 forks source link

Missing Test Case - 1593. Split a String Into the Max Number of Unique Substrings #24901

Open piyushkumar4021 opened 5 days ago

piyushkumar4021 commented 5 days ago

LeetCode Username

piyush_kumar41

Problem Number, Title, and Link

  1. Split a String Into the Max Number of Unique Substrings https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings/?envType=daily-question&envId=2024-10-21

Bug Category

Incorrect test case (Output of test case is incorrect as per the problem statement)

Bug Description

Output for the testcase "ababab" is 4 but it should be 3 because the unique strings will be ["a", "b", "abab"].

Language Used for Code

C++

Code used for Submit/Run operation

class Solution {
public:
    int backtrack(string &s, int start, unordered_set<string> &seen) {
        if (start == s.size()) {
            return 0;
        }

        int maxCount = 0;
        string currentSubstring;

        for (int i = start; i < s.size(); ++i) {
            currentSubstring += s[i];

            if (seen.find(currentSubstring) == seen.end()) {
                    seen.insert(currentSubstring);
                    maxCount = max(maxCount, 1 + backtrack(s, i + 1, seen));
                    seen.erase(currentSubstring);
                }
            }

        return maxCount;
    }
    int maxUniqueSplit(string s) {
        unordered_set<string> hash;
        return backtrack(s, 0, hash);
    }
};

Expected behavior

Invalid answer for the testcase for "ababab".

Screenshots

image

Additional context

No response

exalate-issue-sync[bot] commented 5 days ago

LeetCode Support commented: Hi piyush_kumar41,

Thank you for reaching out with your concern. From the details provided, it seems the goal of the problem is to maximize the number of unique substrings you can get from the string. It appears there might be a misunderstanding regarding the problem's requirement to achieve the maximum count of unique substrings rather than a specific arrangement. Kindly re-examine the problem statement and examples to ensure alignment with the expectations. Additionally, reviewing community discussions on the problem page might provide further insights or alternative perspectives that may help.

If you have any further questions or need additional assistance, please feel free to reach out.

Best regards,
LeetCode Support Team

FoxtrotOnce commented 5 days ago

You can split it into ["a","ba","b","ab"], which is 4