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
Is this because this code make unnecessary loops? Or what else might the problem be here? # Solution.py for https://www.hackerrank.com/challenges/string-similarity import sys for line in sys.stdin: if line.islower(): line = line[:-1] # line will be compared to suffix line_length = ...
String Reduction wow very misleading question. spent alot of time, in vain, using the standard dynamic programming analysis, got no where because the choices of reduction for a string cant seem to be reduced to choices of reduction for its substrings, so the problem cant seem to be analyzed ...
My working solution is here: def parse_input(): string = raw_input() return string def check_string(string): check_funs = [str.isalnum, str.isalpha, str.isdigit, str.islower, str.isupper, ] return [any(fun(char) for char in string) for fun in check_funs] def print_output...
In C#, I am trying to extract the latter portion of a string that is separated by a hyphen. For instance, I have a string "abc-def-gef", and I want to remove the first part before the first hyphen and obtain "def-gef". Can you assist me in finding a solution?