Skip to content

Instantly share code, notes, and snippets.

View sreevidyavutukuru's full-sized avatar

sreevidyavutukuru

View GitHub Profile
Str1 = "aaabbcgfhh"
SubStrs = []
SubStrd_Dict = {}
for i in range(1,len(Str1)):
#SubStrs.append(i)
SubStrs = []
for j in range(0,len(Str1)-i):
SubStrs.append(Str1[j:j+i])
#print SubStrs
SubStrd_Dict[i] = SubStrs
def palindrom(string1):
i = 0
j = len(string1) -1
flag = True
while i<len(string1)-1 and j >=0:
if string1[i] != string1[j]:
flag = False
break
else:
#Kth rank value
scores = [10,20,12,3,8]
scores.sort()
rank_scores = {}
for i,val in enumerate(scores):
rank_scores[i+1] = val
print rank_scores[3]
class Solution(object):
def lengthOfLongestSubstringTwoDistinct(self, s):
"""
:type s: str
:rtype: int
"""
sublen = 1
substrings = []
result = {}
for i in range(0,len(s)+1):
sqr = math.sqrt(10000)
print sqr
list1= []
i = 1
while i <=10000:
list1.append(i)
i += 1
x=2
for x in list1:
import math
def index(list1, n):
startIndex = 0
endIndex = len(list1) - 1
while startIndex <= endIndex:
mid = startIndex + int(math.floor((endIndex-startIndex)/2))
if list1[mid] == n:
print n
print mid
list1 = [10,20,3000,10,-1,12000,-10,20,80,300,100,-30,90,10000]
i = 1
j = 1
maxtotal = 0
index_subset = {}
total = []
result = []
for val in list1:
tempmax= maxtotal+val
def rotate( nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: void Do not return anything, modify nums in-place instead.
"""
if len(nums)==1:
if k ==1:
return nums
'''Given an integer between 0 and 999,999, print an English phrase that describes the integer (eg, “One Thousand, Two Hundred and Thirty Four”).'''
dict_units = {0:'',1:'one',2:'two',3:'three',4:'four',5:'five',
6:'six',7:'seven',8:'eight',9:'nine'}
dict_tens = {0:'',10: 'ten',20:'twenty',30:'thirty',40:'fourty',50:'fifty',60:'sixty',70:'seventy',80:'eighty',90:'ninty'}
steps = {0: '', 1:'thousand', 2 : 'million', 3: 'billion'}
def exp(n):
strn = str(n)
if len(strn) == 3 :
list1 = [1,2,2,3,4,5,6,9]
def pair_sums(nums,n):
dict_nums = {}
result = []
nums.sort()
for val in nums:
if dict_nums.has_key(val):
dict_nums[val] += 1
else:
dict_nums[val] = 1