{"id":22513634,"url":"https://github.com/emahtab/palindrome-partitioning","last_synced_at":"2026-02-02T14:01:56.726Z","repository":{"id":79525705,"uuid":"277333671","full_name":"eMahtab/palindrome-partitioning","owner":"eMahtab","description":null,"archived":false,"fork":false,"pushed_at":"2020-07-05T15:58:38.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T01:30:25.736Z","etag":null,"topics":["backtracking","leetcode","palindrome-partitioning","problem-solving"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-07-05T15:48:30.000Z","updated_at":"2020-07-05T15:59:29.000Z","dependencies_parsed_at":"2023-05-10T17:15:40.119Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/palindrome-partitioning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eMahtab/palindrome-partitioning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpalindrome-partitioning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpalindrome-partitioning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpalindrome-partitioning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpalindrome-partitioning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/palindrome-partitioning/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fpalindrome-partitioning/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260026311,"owners_count":22947767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtracking","leetcode","palindrome-partitioning","problem-solving"],"created_at":"2024-12-07T03:13:47.987Z","updated_at":"2026-02-02T14:01:51.694Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Palindrome Partitioning\n# https://leetcode.com/problems/palindrome-partitioning\n\n# Implementation :\n```java\nclass Solution {\n    public List\u003cList\u003cString\u003e\u003e partition(String str) {\n        List\u003cList\u003cString\u003e\u003e res = new ArrayList\u003c\u003e();\n        if (str.length() == 0) return res;\n        helper(res, new ArrayList\u003cString\u003e(), str, 0);\n        return res;\n    }\n    \n    private void helper(List\u003cList\u003cString\u003e\u003e res, List\u003cString\u003e current, String str, int start) {\n    \t// System.out.println(\"helper(res, current, str, \" + start+\")\");\n        if (start == str.length()) {\n        \t// System.out.println(\" Adding : \" + current);\n            res.add(new ArrayList\u003c\u003e(current));\n            return;\n        }\n        \n        int n = str.length();\n        for (int j = start; j \u003c n; j++) {\n            if (isPalindrome(str, start, j)) {\n            \t// System.out.println(\"Palindrome : \" + str.substring(start, j + 1));\n            \tcurrent.add(str.substring(start, j + 1));\n                helper(res, current, str, j + 1);\n                current.remove(current.size() - 1);\n            }\n        }\n    }\n    \n    private boolean isPalindrome(String str, int start, int end) {\n        while (start \u003c= end) {\n            if (str.charAt(start++) != str.charAt(end--)) \n            \treturn false;\n        }\n        return true;\n    }\n\n}\n```\n\n**Runtime Analysis :**\n\nTime complexity: O(n*(2^n))\n\nFor a string with length n, there will be (n - 1) intervals between chars.\n\nFor every interval, we can cut it or not cut it, so there will be 2^(n - 1) ways to partition the string.\n\nFor every partition way, we need to check if it is palindrome, which is O(n).\n\nSo the time complexity is O(n*(2^n))\n\n# References :\n1. https://www.youtube.com/watch?v=A0wENqSIxK4\n2. https://leetcode.com/problems/palindrome-partitioning/discuss/41963/Java:-Backtracking-solution./40308\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fpalindrome-partitioning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Fpalindrome-partitioning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fpalindrome-partitioning/lists"}