A set of practice note, solution, complexity analysis and test bench to leetcode problem set - leetcode/CountSubArrayFixBound.drawio at b58bcceb0ea27d0756ad72fb6a64b3b547fae221 · brianchiang-tw/leetcode
18.4 Write a method to count the number of 2s between 0 and n. 这道题给了我们一个整数n,让我们求[0,n]区间内所有2出现的个数,比如如果n=20,那么满足题意的是2, 12, 20,那么返回3即可。LeetCode上有一道很类似的题Factorial Trailing Zeroes,但是那道题求5的个数还包括了因子中的5,比如10里面也...
1packageLeetCode;23publicclassL38_CountAndSay {4publicString countAndSay(intn) {5if(n<=0){6returnnull;7}8String res="1";//第一行结果9intlen = 0;10for(inti=1;i<n;i++){//第二行及以后11intcount=1;//数字出现次数12if(i==1){//第二行13res="11";14}else{//不加else的计划,...