Adds a solution for the LeetCode Daily Challenge on 21st October, Monday, implemented in Java.
The solution includes a backtracking approach to find the maximum number of unique splits of a given string.
š Issue Reference:
Fixes issue: Solves the problem posted in the LeetCode Daily Challenge for 21st October.
š Checklist:
Please ensure the following before submitting your PR:
[x] I have placed my solution in the correct folder (solutions/day21/).
[x] My code follows clean coding practices and is efficient.
[ ] I have added comments in my code to explain the approach.
[x] I have tested the solution on LeetCode and it works correctly.
š§ Solution Details:
Language Used: Java
Approach: The solution uses a backtracking approach to explore all possible ways to split the string into unique substrings. It starts at the first character and tries to create substrings of varying lengths. For each substring, if it is not already in the set of current substrings, it is added, and the function continues to explore further splits. The maximum number of unique splits is updated whenever a complete partition of the string is found.
Time Complexity: O(2^N), where N is the length of the string. This is because all combinations of substrings are explored.
Space Complexity: O(N), due to the recursion stack depth and the space required for storing substrings in the set.
š Additional Notes (if any):
Edge cases handled include:
An empty string (""), where the output is 0.
A string with all identical characters (e.g., "aaaa"), where each character could be considered a separate unique substring.
An alternative approach could involve dynamic programming, but backtracking provides a straightforward solution for this problem.
The solution has been tested against multiple test cases on LeetCode and has passed all of them successfully.
š What does this PR do?
š Issue Reference:
Fixes issue: Solves the problem posted in the LeetCode Daily Challenge for 21st October.
š Checklist:
Please ensure the following before submitting your PR:
solutions/day21/
).š§ Solution Details:
š Additional Notes (if any):
""
), where the output is0
."aaaa"
), where each character could be considered a separate unique substring.