1a =raw_input().strip()2b =raw_input().strip()3cnt =0;4foriinxrange(len(a)):5cnt += 1ifa.find(b, i, i+len(b))!= -1else06printcnt
Find a string check this def count_substring(string, sub_string): count =0 for i in range(0,len(string)-len(sub_string)+1): try: if string[i:i+len(sub_string)]==sub_string: count+=1 except IndexError: break return count
代码如下: 1importjava.util.*;23publicclassSolution {4privatestaticintneed = 0;5privatestaticinthasFound = 0;67privatestaticvoidswap(int[] ar,inti,intj){8inttemp =ar[i];9ar[i]=ar[j];10ar[j]=temp;11}12privatestaticintPartition(int[] ar,intstart,intend){13intpivot =ar[end];14inti ...
Here’s a quick example. Let’s say you wanted to concatenate a string in C#, but you have no idea how. All you would have to do is search the query and hit enter. You’ll immediately get the accurate solution, as well as the opportunity to edit the code right in your search resu...
1 <=T <= 15 0 < N < 1010 Output Format Number of digits in that number exactly divides that number. 题解: 1importjava.io.*;2importjava.util.*;345publicclassSolution {67publicstaticvoidmain(String[] args) {8Scanner in =newScanner(System.in);9intt =in.nextInt();10for(inti = 0...
classSolution {public:/** * @param A: An integer matrix * @return: The index of the peak*/vector<int> findPeakII(vector<vector<int> >A) {intn =A.size();intm = A[0].size();inti =1, j =1;while(i < m -1&& j < n -1) ...
typedef unordered_map<int, unsigned>HM;classSolution { HM go(TreeNode*p) {if(!p)returnHM(); auto rl= go(p->left); auto rr= go(p->right); HM r=rl;for(auto &kv : rr) r[kv.first] +=kv.second; r[p->val] ++;returnr; ...
classSolution {public:intfindDuplicate(vector<int>&nums) {intnp =nums.size();intn = np -1;ints =1, e =n;while(s<e) {intmid = (s + e) /2;intcnt =0;for(auto v : nums)if(v <= mid) cnt++;if(cnt >mid) { e=mid; ...
* int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * };*/classSolution { vector<vector<int>>ret;intgo(TreeNode *p)//return max height{if(!p)return0;inthl = go(p->left);inthr = go(p->right);inth = max(hl, hr...