CoolFace
Datasetpublic

TheRealSamuel/LeetCodeProblem

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes564downloads
1{2    "id": 3210,3    "name": "count_beautiful_substrings_i",4    "difficulty": "Medium",5    "link": "https://leetcode.com/problems/count-beautiful-substrings-i/",6    "date": "2023-11-19 00:00:00",7    "task_description": "You are given a string `s` and a positive integer `k`. Let `vowels` and `consonants` be the number of vowels and consonants in a string. A string is **beautiful** if: `vowels == consonants`. `(vowels * consonants) % k == 0`, in other terms the multiplication of `vowels` and `consonants` is divisible by `k`. Return _the number of **non-empty beautiful substrings** in the given string_ `s`. A **substring** is a contiguous sequence of characters in a string. **Vowel letters** in English are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`. **Consonant letters** in English are every letter except vowels. **Example 1:** ``` **Input:** s = \"baeyh\", k = 2 **Output:** 2 **Explanation:** There are 2 beautiful substrings in the given string. - Substring \"baeyh\", vowels = 2 ([\"a\",e\"]), consonants = 2 ([\"y\",\"h\"]). You can see that string \"aeyh\" is beautiful as vowels == consonants and vowels * consonants % k == 0. - Substring \"baeyh\", vowels = 2 ([\"a\",e\"]), consonants = 2 ([\"b\",\"y\"]). You can see that string \"baey\" is beautiful as vowels == consonants and vowels * consonants % k == 0. It can be shown that there are only 2 beautiful substrings in the given string. ``` **Example 2:** ``` **Input:** s = \"abba\", k = 1 **Output:** 3 **Explanation:** There are 3 beautiful substrings in the given string. - Substring \"abba\", vowels = 1 ([\"a\"]), consonants = 1 ([\"b\"]). - Substring \"abba\", vowels = 1 ([\"a\"]), consonants = 1 ([\"b\"]). - Substring \"abba\", vowels = 2 ([\"a\",\"a\"]), consonants = 2 ([\"b\",\"b\"]). It can be shown that there are only 3 beautiful substrings in the given string. ``` **Example 3:** ``` **Input:** s = \"bcdf\", k = 1 **Output:** 0 **Explanation:** There are no beautiful substrings in the given string. ``` **Constraints:** `1 <= s.length <= 1000` `1 <= k <= 1000` `s` consists of only English lowercase letters.",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "s = \"baeyh\", k = 2",12            "output": "2 "13        },14        {15            "label": "Example 2",16            "input": "s = \"abba\", k = 1",17            "output": "3 "18        },19        {20            "label": "Example 3",21            "input": "s = \"bcdf\", k = 1",22            "output": "0 "23        }24    ],25    "private_test_cases": [26        {27            "input": [28                "\"ctjodkwsatjlyxpxkwchvkhtxvdkirphcggiftuifrnpefjywshxmcsrqaeuuxlfziwtskuafkkkpoxdqsiqiauuvbjbwpnusmszocicejecssspzhfhtgmamgfojgpniumprheckmxwyhzzulyiezvuxnpshpgekojeoltwhezlrsppeapbvyyeuhhvpbeezuwdcwaxkgyalprgzmtkdpghzjivndasjxuogzeigrjcxquuhcowvshidesjlnthwlulbggwrbgvwbrftdxfjmwkoqtntbkgfgqsupstibrlnvopkhvmzbhoabcyfvnlcpvpaufaqjsgekqiffaakeivfareljuprtmleoooufxvxxdryjiesxhqk\"",29                67030            ],31            "output": 032        },33        {34            "input": [35                "\"tvfpodepegsskmnhugzuomwnodhhxxsugmfqzzwqpegnghbghdfpqsydgihjcpjhmbnnbecjcvzonrocnxbblwbupajmsxfsucxamklcxvgzletbwxfrihitieilutroggsdwhmdxnrkyxxdtrvazjyoiuhnykkpqrhqktoqezcjdoffjfyyjghuzocyhnnwlmetiimkligshhpeirfqkdvcmshgzomzjoxgldmhwwqmqqvjfjylcleqogztdzdoywryrvjrublrfqmplkbnscuvsprsdapmjqtfpkoxodtdnnngwigluymsrklrdwvahxdyuigxprnpknqtjeaqzduwgcdwobvdulqadlbmszprzisjbzdwpcgjbookenuqrmtsvvhmmqgxxaltfwqzvpjrcikadjkalptiyfasdeuoydtrfxxycxekvvghcmafsckpjyoclvguggehihivkljyjzhwmzclhfwmyqxnhfhmehcejtlkwhfqeahpllnrwojvqzwkirjmaaqkdgrwckqniqdyxsmitcvzaoqfphadpucazxihcfxkfikqnykcmquzlnivndlveyqlnzsrgyctsmqzztvleukczwukelqzszqsovtdvjdihfgmgkdqrzlhwoviqdvkgfrzrsrdbxytjguxwblmsetjpbdukchsrtqeuzpuvcrhthpmqdcpsrencgobuzyktsnpmrypfxluyqjzyqhjampzjyfkxhxpqtonywvcgzdknydytrygmwcbsbgfvvlauahexohoxsfmpendmybcbzrzwtbnrbfkagcdkshtzeebkebacvppgokozkdqmqgidggkepipgeyelqnvyizverbnomy\"",36                45537            ],38            "output": 039        },40        {41            "input": [42                "\"leayshlhovhjmcojnpbvyafruwyiboquodtgkvnatbettskfpoggqeguohblepimtdpsyazfvhpuxeifztahiyluurpmhkctucdncaebfffjlshilbbynaiilebmndawrijxtxggdejacgtpsgwioflktowrdlxvfgwgtmyhblxalbaizcqgkjgdtqvhhdittpankikrqdapubngogzapehelusnrxfooqsdgnmabzqemswtzwylokeyrpefupmmtiphvrereizxycfhmhisunbusudbspeckdxlsvyvojjivssxzrvxtkbgxarwzhhecvfbbnbpaewpucwxquoqbrprnbnktycgewtfhoojblyajtoojtbykmcgsvwsnfjwrhonubybfxsptubswmqmxhjlbxaaxedsgtiqrgslsapkmvldejtcypuqdhibyxflxxdrqpnaygfgjohcqywnsnlgfbtfykrmhgbtupeiysublosqsypsyoguxnjscwgxfekdnexutswccnymivgukcfvybyhgnteyesvwjsmdhoaotcoocyafqyvyxwctkdcaxgphwxpyucxmhmxhhmkgutdvbbalpxqasjixqfhdfmcfrhmesceaiiucfsapduxugkunjzhnhuuvkivdmglvwwrswhdvsspskuosvsasuwkwlakxevpnfobnwjzskcoowhhkslfektjiabodsthvphiiexolmspqnwfvymxoqnaavlsdsucplrskgsjwnobjmhujiewantihxmevqtxdaloextzsnosctwdotzvvpccijaffxubarqwfkxpfrlhghbgtghvwvrlxnbogbdsxlfwcaynnzacbmqgjyarremnhwfrjpcnerqcnvpql\"",43                48044            ],45            "output": 046        },47        {48            "input": [49                "\"ilsusmrloyodrgzrvyzcedvjlyoegzsgkedxnsxmblbjmjsjsvkoyskkarlffrgaultjmfnstrvybuykbojuikyspnwaknfvouomcrahinbnnvvaqyhxiqbjenitkkhcshdjfvmzvvhmdjldyjpmalyvxgmeyfvmjgkadspzqeuxomxxsfhaogncgfwouqrydhqkhbnqkklmwdytrdgnnkudzljvlncapnuvrdqvnyatwskakgxqyqmrupjzbgmsuadiaytrxyudapentstabfmfolztpw\"",50                90751            ],52            "output": 053        },54        {55            "input": [56                "\"uzltyrfwnthpokxlyfsxa\"",57                5858            ],59            "output": 060        },61        {62            "input": [63                "\"hkuhlqqpkswnlwsjemrdgerllttyetnavwttgmanngkczcpfjjkxubgxlmeshusvzyaigvvstclhqzbhbipwgneluwwnrywyaecqibcnbjnmlubrkgnuawfgdxzobrgxbbhfrgnpgfczynqwtwzlwqnyvmtvyakmpdibviaesyfbkyzqwyfcqrifncshxmpfjylbnzfewocinjgoopcvwpmmyafaumdhonhddmxadfpfwylnfqwjvbtcpxwicuunxbnrhkzxoknhyazanvnlxnvngxhmoqsogmendqmylkxfkqtuymdrlbtbhcggqkcxbdsgkbqzdirysylwasnwgbdzjyvioxvztqqavxcvpyzfpkpyykyauutqnruraddefnqsoezuovcfrfcswpewrrbpexvkelcryntpxnxepklsxewoifrqrwyhinbknfgxypfvcrgyinxywmpsprcdchlgcrsluzflyhrnbjczxnqzgbhcjghxymwpfzsynllmtfazwdtdpzwjowbxwkwtkpijlktsxwxyehbwnqiojorvhsnxgfapnsynsvtlgximwaanzxqzpmurhmosvjehdlgscpdwlurfflvgdfstyjoqzizwxyrwlxposqzfljtdxbtgijzccshgdvltu\"",64                53965            ],66            "output": 067        },68        {69            "input": [70                "\"fjkajpxyfvsjpymysmtijuznbvdekynnkxmrvszamxultzdgdmwegabwawlawtaqhvlniejgfzbhpvepbpouiqaguqyjutipgwdttjhfnbzxhjprvxynhakuouxlbtgwllzzposfqrijtpodurywpziwzknrlyzikpscbhepalcsyhvchyiuyqfsidbszbwbffojlpchyamdxrfyfvmovamapfuztrmgxuxpgvhixwbkqlrjzcvptubzqarkfnspagyrokliheotzbetfjrmdussosgjzossoysviydyinnplcdayxcltyiqkhmptakdjqlqqhmghykyceqtglicnwszvkugnnwlnqcbxzvpihfdtfntnzrcxnjbdpfiqlypfezduwlrzlryqekpvgkrazgjvqepduazhchgwrufsfzhvqwikbgyqjhsduuzlzgvhiedukrenrszaogadyamrryecslmizctcqkyhhrxoiwuuzggwoebceezvnbplswbbboebbyehkxgisbjyyuecftecovyyurxdrbqhymmvaqwojqtwkacxleeobyhimsqjghpgmlksxtugpbowdcizpyrfxvxmjhofkhrdtfhipugldaplotruuaitlbftcsuasrttqbsmpbaulyjzqzqzywvysbteptiqxmeotwiclugeqrsnvshqhzldotnqlbybvsukykmzkrkclblejcrbiqiwdvjkpnzdolfphrfustijcjibuvwuwdgqszrxkjlxsrfranvdvtgfgpodxecqazqj\"",71                35172            ],73            "output": 074        },75        {76            "input": [77                "yacizlutlzqkeangldcdymlchghvplczwxbzwsdkobethxxnqfhzllkukmmzpygfronnqgfdaidhcfosgxftzjhapywdyqjbdqvyvyqhnkinceqfvmtlbyqjystkgcjzkgsbnzyushkctcvqwybmgbezqwbggkhuejazgbndpzqkqekktmfddrsdquivxbmxzcvabzwfeendyphxhvzhqwkyderepayqwlkbypovwkzlldkkiyakofflvlzqiplsghkguyfwmlzrrccynbqd",78                35279            ],80            "output": 081        },82        {83            "input": [84                "jiydlbcrhaatomioquyntircneoelotgbxnddyjhjvleqbcjbhhhvoofjdthnftpqmnggyfffyqkmhgjxaxxxfxrqpmznhuuksxdckjbhscikvjiurzbbwkozguhjnwttclnlczhivubbgkogbvgzeexfxpkraknvycwobkqfqilvcnggcjdjtdiqiuaueewvajvxupqnxujlhjkpknbitkvllcghymnkxl",85                78086            ],87            "output": 088        },89        {90            "input": [91                "hzfcxspkmcuiqorblkgzppvelehfqcsssmbeimpduksuimvjlxoacsgspgormnoiolghntatjqfnubwtdrmwlzsbchejcoymimsoqsflmebcyqpjbjaqjvygpjvjtzdtmblykmzehyruojuhglwpuawxzcgobjpnnclgcpijrjrtmibluyzijyxjltjbcatnubejtjnnrbskmnhwoqxhxqmslbhzsxgrrhjrdscqsfbvipsxyhargnrexobvqbgbescsrihauzveaduckrotsrfoysdvvfhqgjwlmvsjxsmiifworvuyfzlvogjtpowmiaqouefvxfexzaqlesuvvlkntcja",92                23193            ],94            "output": 095        }96    ],97    "haskell_template": "beautifulSubstrings :: String -> Int -> Int\nbeautifulSubstrings s k ",98    "ocaml_template": "let beautifulSubstrings (s: string) (k: int) : int =  ",99    "scala_template": "def beautifulSubstrings(s: String,k: Int): Int = { \n    \n}",100    "java_template": "class Solution {\n    public int beautifulSubstrings(String s, int k) {\n        \n    }\n}",101    "python_template": "class Solution(object):\n    def beautifulSubstrings(self, s, k):\n        \"\"\"\n        :type s: str\n        :type k: int\n        :rtype: int\n        \"\"\"\n        "102}