FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 2360,3 "name": "substring-with-largest-variance",4 "difficulty": "Hard",5 "link": "https://leetcode.com/problems/substring-with-largest-variance/",6 "date": "2022-04-30",7 "task_description": "The **variance** of a string is defined as the largest difference between the number of occurrences of **any** `2` characters present in the string. Note the two characters may or may not be the same. Given a string `s` consisting of lowercase English letters only, return _the **largest variance** possible among all **substrings** of_ `s`. A **substring** is a contiguous sequence of characters within a string. **Example 1:** ``` **Input:** s = \"aababbb\" **Output:** 3 **Explanation:** All possible variances along with their respective substrings are listed below: - Variance 0 for substrings \"a\", \"aa\", \"ab\", \"abab\", \"aababb\", \"ba\", \"b\", \"bb\", and \"bbb\". - Variance 1 for substrings \"aab\", \"aba\", \"abb\", \"aabab\", \"ababb\", \"aababbb\", and \"bab\". - Variance 2 for substrings \"aaba\", \"ababbb\", \"abbb\", and \"babb\". - Variance 3 for substring \"babbb\". Since the largest possible variance is 3, we return it. ``` **Example 2:** ``` **Input:** s = \"abcde\" **Output:** 0 **Explanation:** No letter occurs more than once in s, so the variance of every substring is 0. ``` **Constraints:** `1 <= s.length <= 104` `s` consists of lowercase English letters.",8 "test_case": [9 {10 "label": "Example 1",11 "input": "s = \"aababbb\"",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "s = \"abcde\"",17 "output": "0 "18 }19 ],20 "constraints": [21 "1 <= s.length <= 104",22 "s consists of lowercase English letters."23 ],24 "python_template": "class Solution(object):\n def largestVariance(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n ",25 "java_template": "class Solution {\n public int largestVariance(String s) {\n \n }\n}",26 "metadata": {27 "func_name": "largestVariance"28 }29}