Short and Simple Python solution with Backtracking:
def getMinLengthSubsequence(nums, sub):
def search(nums, sub, startn, starts):
if starts >= len(nums) or startn >= len(nums):
return -1, -1
for idx in range(startn, len(nums)):
if nums[idx] == sub[starts]:
if starts == len(sub) - 1:
return idx, idx
start, end = search(nums, sub, idx + 1, starts + 1)
if start >= 0:
return idx, end
return -1, -1
start, end = 0, float('inf')
for idx in range(len(nums)):
if sub and nums[idx] == sub:
startx, endx = search(nums, sub, idx, 0)
if startx != -1 and endx - startx < end - start:
start, end = startx, endx
return start, end
def advance(nums, counts, i, j, X, Y):
while 0 <= i < j and counts[X] > counts[Y]:
if nums[j] == X:
counts[X] -= 1
j -= 1
if nums[i] == X:
counts[X] -= 1
i += 1
i += 1
j -= 1
return i, j
def largestContainingXandY(nums, X, Y):
counts = collections.Counter(nums)
i, j, res = 0, len(nums) - 1, 0
while i < j:
i, j = advance(nums, counts, i, j, X, Y)
i, j = advance(nums, counts, i, j, Y, X)
if counts[X] == counts[Y]:
res = max(res, j - i + 1)
nums = [7, 42, 5, 6, 42, 8, 7,5, 7, 6, 7]
nums1 = [7, 42, 7, 42, 7, 7, 42, 42, 7, 7, 7, 7, 7, 7, 42]
nums2 = [7, 7]
print(largestContainingXandY(nums1, 7, 42))
res, s = , list(int(x) for x in str(num))
for i in range(0, len(s) - 1):
left = s[:i]
right = s[i+2:]
res += "".join(str(x) for x in left + [max(s[i], s[i+1])] + right),
# I got max 10 digits, so I run maximum 10 times the loop. Each loop takes O(n) time,
# Where n is the length (10). So at the end I have in the worst case a list of 10 elements each one having 10 digits. Getting the minimum will require me 10 comparisons each one taking 10 (I gotta compare every digit).
num = 233614
One line in Python:
def check_patterns(words, p):
for word in words
if len(word) == len(p) and\
len(set(zip(word, p))) == len(set(word)) == len(set(p))
words = ["cdf", "too", "hgfdt" ,"paa"]
p = "abc"
p1 = "acc"
return 1 if random.random() >= 0.5 else 0
return 0 if not (rand_0_5() + rand_0_5()) else 1
deloresrdaniels, Cloud Support Associate at JDA
Crossed the country marketing wool in Nigeria. Was quite successful How to Get Girlfriend Back By Vashikaran Mantra . Spent a ...
amyfreynold, abc at ADP
Hi Everyone, I'm Ammy. I love to build props...everything from a casket to pneumatic monsters.My current pet ...
Robin Strain, Consultant
I am from New york. I am 26 year old. I work in a Central Hardware as a Worker compensation ...
I am randy, 29 year old and I am doing a job. I am doing a job as a plant ...
kaylafgioia, Cloud Support Associate at Absolute Softech Ltd
Hi, I am Kayla from Elkins USA. I am working as Project management and I have professional 3-year experience in ...
markhlee8, Research Scientist at Bank of America
I am a cooking Instructor in New York USA, I Have a degree from the prestigious Culinary Arts Institute of ...
marilynarhea, Computer Scientist at ABC TECH SUPPORT
I live my life very happily by god grace and I am working as a Gaming machine servicer and my ...
JennyReimer, Dev Lead at Adobe
Badminton lover, coffee addict, guitarist, International Swiss style practitioner and TDC honorary member. Acting at the nexus of simplicity and ...
merrillagreerm, Android Engineer at Abs india pvt. ltd.
I am patient, compassionate, and caring when treating and counseling patients in practice, making them feel like they’re in ...
jasonmcarrier, Analyst at Abs india pvt. ltd.
Hello, I live in Houston and I am working as a Convention planner in Roberd's company, I also part ...
EllaFlores, Associate at Alcatel Lucent
Ella , a Tour bus driver in Sounds Great company Inc. A charter bus driver is responsible for providing comfortable and ...
sujijaa565, AT&T Customer service email at ABC TECH SUPPORT
My name is suji. I am working as a Suadela Investment in Tulsa USA . I identify and establish a new ...
johndbutler0, Aghori Mahakal Tantrik at BMO Harris Bank
I consider myself to be driven, proactive, hard working, a team player, creative and absolutely passionate person! I am strong ...
susancmeans, Apple Phone Number available 24/7 for our Customers at Absolute Softech Ltd
I am Susan from Bronx, I am working as a Business management analyst in Brendle's company. I Have a ...
JenniferSRoe, Android test engineer at Accolite software
I am Jennifer from Dublin. I am Photographer, I have experienced in all different kinds of photography -Strong aesthetic sense ...
vickiwgerber, Member Technical Staff at Boomerang Commerce
I am Vicki From San Antonio USA, I am working as an Interior decorator in Golden Joy company. I have ...
EdithJHarden, Random at Axiom Sources
Je suis un professionnel de la gestion des soins de santé avec 2 ans d'expérience en supervision d'établissements ...
neshujaha, Member Technical Staff at BMO Harris Bank
I am Neshu, a Camera Operator with a creative eye for detail and dedication to quality work. I am always ...
Discover the cheapest packers and movers in Gurgaon at best price with smooth and hassle free relocation. We provide truck ...
kellydbrown23, Jr. Software Engineer at Auto NInja
I live in College Park USA with my family, and my current job is clerk in Luria’s company. I ...
Soccer lover, coffee addict, guitarist, International Swiss style practitioner and TDC honorary member. Acting at the nexus of simplicity and ...
loreleijhansen, Aghori Mahakal Tantrik at ABC TECH SUPPORT
I am Lorelei.I am working in a store as a Bonus clerk promoting the development, and implementation and solutions ...
elmothure, Backend Developer at ABC TECH SUPPORT
Social work is a practice-based profession that promotes social change, development, cohesion and the empowerment of people and communities. Social ...
josephcday6, Android Engineer at Absolute Softech Ltd
I am SEO Executive in Elek-Tek company. I live in Morgantown USA. I won’t write any details about Best ...
johnagragg0, cox customer service at Deloitte Consulting LLP
I am friendly, I am a hard worker, even through difficult circumstances, I want to know about How to identify ...
merrittmonique9, Android Engineer at AMD
I am Monique and working in high court from last 20 years.Handel many cases in my career.Build and ...
PriscillaRYoung, Aghori Mahakal Tantrik at Absolute Softech Ltd
Hi, I am Priscilla from California. I am working as a Business management consultant in Quality Merchant Services company. I ...
Want to purchase best quality silencer at affordable price manufactured by top most trusted brand Innovative Arms.
Contact Stonefirearms now!
kiyanshak, Associate at Adobe
I am a skilled software developer and have 5 years experience as a data coder operator. I have certain skills ...
ethelynfrose, Computer Scientist at 247quickbookshelp
Hello, I am Ethelyn and I live in Lake Worth, USA. I am working as a Dog Trainer and Dog ...
SarahSKelly, Game Programmer at Akamai
I am Professor, and I am also a skilled fiction writer. I have a collection of novels published in the ...
cherylbgrant, Python Experienced at Bankbazaar
Je suis Cheryl, une traductrice multilingue passionnée avec 3 ans d'expérience dans la traduction de différentes langues telles que ...
LizaZeiger, Animator at Accenture
I am a Loan processing clerk. My work is assembling, administering and processing your loan application paperwork before it gets ...
marywwaldrop7, Computer Scientist at Chelsio Communications
I am Mary ,working in the field of training and development coordinator for three years, focusing on teaching English as ...
RichardWParks, Accountant at ADP
markemorgan007, Applications Developer at Big Fish
I am Mark From Fresno city in USA.I working as a tour guide and also help for make a ...
- frestuc August 23, 2016