NearlyeveryonehaveusedtheMultiplicationTable.Butcouldyoufindoutthek-thsmallestnumberquicklyfromthemultiplicationtable? GiventheheightmandthelengthnofamnMultiplicationTable,andapositiveintegerk,youneedtoreturnthek-thsmallestnumberinthistable. Example1:Input:m=3,n=3,k=5Output:Explanation:TheMultiplic...
Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring. Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters. Example1:Input:“abc”Output:3Explanation:Threepalindromicstrings:“a”,“b”,“c”.Example2:Input:“aaa”Output:6Explanati...
堆排序 就是构建堆,然后取出堆顶元素即可 代码如下 include<iostream> include<ctime> include<cstdlib> usingnamespacestd; voidadjust(inta,intindex,intSIZE); voidHeapSort(inta,intSIZE); voidswap(inta,intx,inty); voidprint(inta,intSIZE); voidinsertHeapSort(inta,intSIZE); voidinsert(inta,intSIZE); intmain...