THIS IS HOW IT WORKS'
lets talk about the case when k<s.size() // coz it is confusing lol\n\nit means we have to do k partitions\n\nsuppose no of odd occuring characters be : o\nassu
lets talk about the case when k<s.size() // coz it is confusing lol\n\nit means we have to do k partitions\n\nsuppose no of odd occuring characters be : o\nassuming o<=k\n\n----- ----- ----- ----- ----- ----  -----\nsuppose these are k partitions, of different lengths ( might be of same length too)\ni am represeting them by ----  ----  ----- -----  , where a character is present at \' - \' \n\nnow there are 2 subcases , either all of the k partitions contain one odd character\n\nhere q->denotes any character with odd freq \n---q1---  ---q2---  --q3--  --q4--  --q5-- \n\n---q1--- is one partition , while ---q2--- is another and so on\n\nsuppose character a and b have odd frequeny, so q1 can be a or b\nand q2 can be b or a respectively\n\nso after eliminating "odd frequency of odd occuring characters"\nWE KNOW know every character has even freq.\n\nnow we can fill remaining spaces with elements .\n\n---q1--- | ---q2--- | ---q3---| ---q4---\n\nthese are the partitions and we are left with characters having even freqency,\nand the remaining length to be filled in all the partitions is s.size()-[q1+q2...(odd frequency)]\nif any position of any partition is filled with any character,\nwe know that characters have even freq , so corresponding palindromic [reverse right to left]\nposition can be filled with same character.\nand we have used 2 characters of same type, so we still have all the characters with even freq.\n\nthis is how we can fill all partitions.\n\nnow same ideology can be extended when o<k\n\n\nsuppose we put one odd character in each partition\nso new partitions formed = o\n partitions we need to create =k-o\nremaining characters left=s.size()-o\n\nnow the ques is can we form k-o palindromic paritions given that\nwe are left with all even freqency characters\n\nnow there are further 2 subcases\nwhen k-o is even\nwe are left with s.size()-o characters where (size()-o>k-o)\nwe know all the size()-o character has its sibling ( it occurs even number of time)\n\nwe need to create k-o ( even no. of partitions)\nso what we can do, choose one character and its sibling, and you can create two new partitions\nnow in last steps, you will be left with characters , having even freq.\nand you can put it anywhere. [ in any partition]\n\n\n\nwhat if k-o is odd?\n\nwe know k-o-1 is even so first fill at the remaining k-o-1 places .\nnow we want to create one new partition right?\nplace all the remaining characters in that partition.\n\n\nIT CAN BE SHOWED THAT WE CAN ALWAYS CONSTRUCT K-PALINDROMS!\n;) THIS IS INDEPTH PROOF OF THE SOLUTION :D\n\ni\'ve not considered the trivial cases when s.size()<k || s.size()==k ;) they are self explanatory!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
[]