s="Hello HOw you are Doing Today" s1="goa" a="123nk" m=" " k=",,,..mks..orange" t="r\ti\tg\th\tt" print(s.capitalize()) print(s.casefold()) print(s.center(50,"0")) print(s.count("o")) print(s.endswith("Today")) print(t.expandtabs(3)) print(s.find("o"))#returns -1 if not present print(s.index("o"))#returns exception if not present print(a.isalnum())# returns true for [a-z] [0-9] print(a.isalpha()) print(a.isdigit())#return true for decimals,superscripts and false for fractions print(a.isdecimal())#return true for decimals and false for fractions ,superscripts print(a.isidentifier()) #should start with [a-z] [0-9] or _ , false for space ("my room") print(s.islower()) print(s.isnumeric())#return true for decimals,superscripts fractions print(m.isspace()) print(s.istitle())#Hi Ram What Happened print(s.isupper()) print(" ".join(["i","Love"...
You are given an array (zero-indexed) of N non-negative integers, A 0 , A 1 ,…, A N-1 . Find the minimum sub-array A l , A l+1 ,…, A r so if we sort(in ascending order) that sub-array, then the whole array should get sorted. If A is already sorted, output -1 . Example : Input 1: A = [1, 3, 2, 4, 5] Return: [1, 2] Input 2: A = [1, 2, 3, 4, 5] Return: [-1] In the above example(Input 1), if we sort the subarray A 1 , A 2 , then whole array A should get sorted. ut Solution: class Solution: # @param A : list of integers # @return a list of integers def subUnsort(self, A): s_a=sorted(A) if A==s_a: return [-1] l=len(A) minI=-1 maxI=l ...
Comments
Post a Comment