1a =raw_input().strip()2b =raw_input().strip()3cnt =0;4foriinxrange(len(a)):5cnt += 1ifa.find(b, i, i+len(b))!= -1else06printcnt
Join us Create a HackerRank account Be part of a 26 million-strong community of developers Please signup or login in order to view this challenge I agree to HackerRank's Terms of Service and Privacy Policy. Sign up or Continue with Google LinkedIn GitHub Facebook Already have an account?Log...
【HackerRank】Find the Median(Partition找到数组中位数) In the Quicksort challenges, you sorted an entire array. Sometimes, you just need specific information about a list of numbers, and doing a full sort would be unnecessary. Can you figure out a way to use your partition code to find the...
Download problem statement Download sample test cases Suggest Edits Join us Create a HackerRank account Be part of a 26 million-strong community of developers Please signup or login in order to view this challenge or Already have an account?Log in...
Time Complexity: O(1). 3. Union Merge two groups into one group. public void union(int a, int b) { int rootA = find(a); int rootB = find(b); if (rootA != rootB) { parent[rootA] = rootB; } } Time Complexity: O(1)....
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; i < t; i++){11Long num =...
Find a string Somewhat similar but more efficient defcount_substring(string,sub_string):count=0;foriinrange(len(sub_string),len(string)+1):if(string[i-len(sub_string):i]==sub_string):count+=1returncount count_substring():=0foriinrange(0,len(string)):if(string[i:i+len(sub_string)...
http://saraguru.weebly.com/how-i-solved/find-maximum-index-product-hackerrank #include <cmath>#include<cstdio>#include<vector>#include<map>#include<set>#include<unordered_set>#include<string>#include<iostream>#include<algorithm>usingnamespacestd;intmain() ...
defcount_substring(string,sub_string):count=0foriinrange(len(string)-len(sub_string)+1):if(string[i:i+len(sub_string)]==sub_string):count+=1returncount like mine defcount_substring(string,sub_string):counter=0sub_len=len(sub_string)foriinrange(0,len(string)):ifstring[i]==sub_stri...
hackerrank first repeat word 找出一个string中第一个重复出现的单词; sample: he had had a good son. output: had 句子中可能会出现,comma,colon, semicolon, dash, fullstop/dot 解法:1;dash和dot 都是regular expression中的,出现会有歧义,因此需要加上 转意符\\...