Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
shortest-matching-substring.json41 linesDownload Raw Back to root
1{2  "id": 3692,3  "name": "shortest-matching-substring",4  "difficulty": "Hard",5  "link": "https://leetcode.com/problems/shortest-matching-substring/",6  "date": "2025-02-01",7  "task_description": "You are given a string `s` and a pattern string `p`, where `p` contains **exactly two** `'*'` characters. The `'*'` in `p` matches any sequence of zero or more characters. Return the length of the **shortest** substring in `s` that matches `p`. If there is no such substring, return -1. **Note:** The empty substring is considered valid. **Example 1:** **Input:** s = \"abaacbaecebce\", p = \"ba*c*ce\" **Output:** 8 **Explanation:** The shortest matching substring of `p` in `s` is `\"**ba**e**c**eb**ce**\"`. **Example 2:** **Input:** s = \"baccbaadbc\", p = \"cc*baa*adb\" **Output:** -1 **Explanation:** There is no matching substring in `s`. **Example 3:** **Input:** s = \"a\", p = \"**\" **Output:** 0 **Explanation:** The empty substring is the shortest matching substring. **Example 4:** **Input:** s = \"madlogic\", p = \"*adlogi*\" **Output:** 6 **Explanation:** The shortest matching substring of `p` in `s` is `\"**adlogi**\"`. **Constraints:** `1 <= s.length <= 105` `2 <= p.length <= 105` `s` contains only lowercase English letters. `p` contains only lowercase English letters and exactly two `'*'`.",8  "test_case": [9    {10      "label": "Example 1",11      "input": "s = \"abaacbaecebce\", p = \"ba*c*ce\"",12      "output": "8 "13    },14    {15      "label": "Example 2",16      "input": "s = \"baccbaadbc\", p = \"cc*baa*adb\"",17      "output": "-1 "18    },19    {20      "label": "Example 3",21      "input": "s = \"a\", p = \"**\"",22      "output": "0 "23    },24    {25      "label": "Example 4",26      "input": "s = \"madlogic\", p = \"*adlogi*\"",27      "output": "6 "28    }29  ],30  "constraints": [31    "1 <= s.length <= 105",32    "2 <= p.length <= 105",33    "s contains only lowercase English letters.",34    "p contains only lowercase English letters and exactly two '*'."35  ],36  "python_template": "class Solution(object):\n    def shortestMatchingSubstring(self, s, p):\n        \"\"\"\n        :type s: str\n        :type p: str\n        :rtype: int\n        \"\"\"\n        ",37  "java_template": "class Solution {\n    public int shortestMatchingSubstring(String s, String p) {\n        \n    }\n}",38  "metadata": {39    "func_name": "shortestMatchingSubstring"40  }41}