Devsu Code Jam 2021 - Preliminary Phase
Devsu Code Jam 2021 - Preliminary Phase
1. Maximum distance
Given a text and a subText that might be in the text, return the maximum distance
from the subText to any side of the text. If the subText is not in the text, return -1. The
distance is the number of characters from the subText to any of the text sides.
Example 1:
Input:
● text = abcdefghi
● subText = de
Output: 4
Explanation:
Example 2:
Input:
● text = abcdefgci
● subText = c
Output: 7
Explanation:
Constraints:
text
yfuajpocenamocibexujhalinesvlijlmylxmpexvfddpejowufvkbzkwlmxeoyartjholmpzxeu
hquvmiuhgvasitvtgiexvunqhoeeowkpwbwwvipeptperrnljsomwcnrvpjmhfsjgixkopmxb
gtlogplujljwxodbfczsxgondmgfhpicdroumealpplxkozuusmufmojyatfthxjlkdzewjfvjmij
mkqppvhoedbhxnruuonntgstdbxchxyztnoqttgigyaxtyjlpfckefclzuylaskhgynmopqkbaf
srnvifjuurmafusdqbziqpejdscfvyepevmfodjchakjndqcyvlleoxyadpzcmphchajrrbumoiv
xruwdliknfhgpdjfxreosblkjyjtrmjrqmfjheamkmckipseuzhvqcgyortoaheajxfiziunqgzizij
oawrvjeyvcrmtpedrzkdukhzjjnaiejfxtkfpdpgdhsskfkfyusgfaefpodnprtcwtwfmjtyfwlsiq
tgwnvluxkmvgmvshgikrteakgydwtbnhqfbtnynlwghstcpvufrvjxoehamfbvnjrrccwqgick
bynzjzroyyiirnsdchfbivviqnbmhtercgvqolwzlixigoddxiukmitymvljojpwjjdmteegbqwgov
nxanresklkiabrnlfumxtmuclccbkajcbrmmdzfdzzcftqiuaadcfrfocdpifyrasthgkmufkoyvl
opavsjpmjystcuwtrqxsrymlmjbdapjmtcsberjknhyawbkeeimdmhtpuixkmllpqbjhqpzfyb
emsilpzzrlifxjxhskzengcldevyswdtxqkniuiffjqwdhjushlowheuotpfinwodqzfcjcypgqrtv
pclogidofispdmgdjbscpouxckilknnqcjwydqzfbfnrwfahkmorcndxqwljefekdpafbsdoldb
mkvizvtzko
subText
jfx
Output: _________________________________
text
axucgrzqebtbuxpiyuavccltqwcmpzmmfaakncabbbdxepyevkswxhlellrfobyufmyumror
cgmjilzogezuggtxotzukeifvybxkacmwvkhswcoabmgwknminltbdqexopvysobpautmk
miuipuzfqpmwhwiyzdprxnadedrquxzassyfgrrjmgfenwmynehqnabgajrnfgdfvftghczet
mhcakgnvjuuctufjgoqowhwtozkskaszvfpijugitoextqibynisnfbenweojapwtclszycusagz
wbgavxawzfnuhmpddgzyymuxurdqkfkejsqdesmmzlxuokmloduolwyslonilvhjlqtftyxfo
aopmvvomiddncnwqmxozqbmhuqpksuydcwwwuxvdfwrfiizcccktmfxcpdtunnknagsg
ntpnccgimnqketezhsbyrofjvwoqvturvwzttugivywdnqtzjnkyfdzkqcabyinwsowecczjgw
wcgomuoogaxmbxcwjbjqozjxrzcyojylanjlpcdzgeraxhbaybxsuhcuvlsshmeblbdfaziubu
gweeckkvxqgtdrrsbxparablqpypqtenytfbntudlyakehtwhbbtngusmjaudcbazjfeqjufbilei
wtylkkfkdmtertqzayaohzkuokkuplcwqrcwzxeqlzbhlubycufmwbvsbcseggwpmezxxnx
mjcabibhjlurjtzuxxjartfgqogmrgpjigfazhpoaqggwpakbcxnghxhddcydmzqgsejyrstktdp
caeqpiqnzyebaioirhvlckxamorbriylesbwszzletemgyfcjyhpsmjandcxdrsjvfzuswuoxybt
xzmhjqhbcxbhxdhbxjbrecpuvutlfyamkltfogwklisxhscgvwufckkszpejndjxzsaiuxengwg
bpdssryllxmzgejtwmqyehdtymzivyygtqqbcu
subText
ggwp
Output: _________________________________
text
wmsbexxcherystodmtfvldoaazzwrcbnoxtrprmoxapcdtkedzyxebdeazzadueyvpudeinb
zshoprybjgkaxyyajybslslcnlitdcfzoebcnnqlckjpwihmleezgtbrqmygdlqmabcwmjuzulgx
fbimebehakskuptbizbnxepezlfujlkdtwpmweppkbqgymrepinn
subText
kasasdkydwg
Output: _________________________________
Let numbers be an array of integers. Get the maximum element in the array that
produces the largest sum when adding all the elements that are different from itself.
Example 1
Input:
numbers = [1,1,2,3,4,5,5,5,6]
Output: 2
Explanation:
Both 1 and 2 produce the greatest sum (30), but 2 is greater than 1. Therefore, 2 is
the maximum element that produces the largest sum.
numbers
[4,10,0,-2,10,-3,-9,0,6,10,6,10,-5,10,7,-10,-9,1,-2,-8,-10,9,-4,-9,5,1,-4,-10,2,-8,1,10,9,-1,0,4,9,
7,9,7,-1,5,3,0,2,-7,4,0,7,0,-5,-6,-1,0,4,10,-2,-6,0,9,5,-5,-10,0,-7,-3,-6,5,7,-4,0,4,5,9,-4,4,1,10,1,
-4,4,-4,9,-10,-10,-5,9,-3,4,0,3,-4,-1,2,-1,-5,10,7,-2,-4]
Output: _________________________________
numbers
[4,-10,6,-3,-2,-4,-9,10,0,-7,-4,-9,-4,2,-6,-7,10,1,8,10,5,1,2,-8,2,-10,0,-6,4,-2,-6,8,-3,0,9,-4,4,-5,
4,-8,-1,-3,-8,8,-6,-7,8,6,0,9,2,-3,-4,4,-5,-2,0,3,0,-3,-6,-4,1,-4,-5,3,2,1,4,-8,-8,-3,-6,2,-4,9,-6,-9,0,
9,9,-6,3,-4,0,-7,-5,0,6,-6,-10,4,-2,6,-3,-1,4,1,-3,-7]
Output: _________________________________
3. Simple sequence
Given a number n that represents an index in the sequence, return the corresponding
element in the sequence.
Example 1
Input:
n=0
Output: 1
Example 2
Input:
n=5
Output: 4
Example 3
Input:
n = 76
Output: 39
Example 4
Constraints
Hint
87123641123172368
Output: _________________________________
81239812739128371
Output: _________________________________
Let letters be a string of uppercase English letters and n an integer that represents a
column number. Return the an “excel-like” header title (a string) that corresponds to n
using the characters in letters.
Example 1
Input
● letters = AB
● n=5
Output
BB
Explanation
● n = 0 -> A
● n = 1 -> B
● n = 2 -> AA
● n = 3 -> AB
● n = 4 -> BA
● n = 5 -> BB
● n = 6 -> AAA
● n = 7 -> AAB
Example 2
Input
● letters = ABC
● n=4
Output:
AB
● n = 0 -> A
● n = 1 -> B
● n = 2 -> C
● n = 3 -> AA
● n = 4 -> AB
● n = 5 -> AC
● n = 6 -> BA
● n = 7 -> BB
Example 3:
Input
● letters = ABCD
● n = 83
Output:
DDD
Constraints
Consider that letters can have repeated characters, thus, you can get the same
header title for multiple columns.
letters
LJVRKMMMNUXPRUP
9954554
Output: _________________________________
letters
FHIK
22525
Output: _________________________________
Given a rectangular matrix of integers m, consider all the paths starting from the top
right to the bottom left corner and return the minimum sum of numbers among all
paths.
You can only move in two directions: left or down.
Example 1
Input:
m = [[0,0,0],[0,1,1], [0,1,1]]
Output:
Explanation:
The sum of the elements in the following path, which is 0, is the minimum.
Example 2
Input:
Output:
Explanation:
The sum of the elements in the following path, which is 2, is the minimum.
m
[[-7,20,14,-25,20,22,19,5,-14,2,17,23,2,2,19,-22,23,-16,-2,11,-4,19,17,10,-10,-7,-13,2,8,19,-
9,-20,25,22,-15,13,9,-9,-24,21,13,21,-19,9,14,6,22,-13,-6,18],[-20,-8,23,-1,-5,-19,21,17,-8,-4
,14,-8,20,7,-12,-16,-18,-5,-21,-6,20,-19,5,2,22,-17,-17,-14,2,-20,-2,11,18,16,1,22,-20,-15,6,-
7,2,25,-17,18,-5,19,2,-6,-25,-15],[20,7,17,-23,12,10,-18,19,8,-17,-23,-5,19,-8,-2,21,0,5,-7,-6,
14,-20,11,24,6,-19,-25,-7,14,19,-6,-8,-22,18,-16,-2,-21,-25,24,24,3,-6,25,-10,-1,-1,21,-13,1,-
6],[7,-15,11,0,5,-5,-2,-9,13,-5,9,16,5,0,-17,-24,-7,13,5,25,-20,15,-10,-20,-12,-19,-1,1,-20,-10,
-8,-6,-12,-3,17,7,16,18,19,12,-12,22,21,7,20,-24,3,-6,14,18],[-17,17,5,-23,-19,10,-23,-24,-1
3,-13,-13,-4,0,-22,17,-16,-9,1,-25,24,-5,6,21,17,-14,0,-20,-23,20,-5,6,25,-16,3,15,9,-8,20,-9,-
23,12,25,16,23,-18,-15,8,-5,-1,0],[15,-16,-17,-7,-20,-6,1,-18,22,19,-2,-12,-2,-6,-18,-15,11,8,-
11,7,10,14,23,9,12,-21,0,-20,5,25,-2,5,11,-8,18,-18,21,-11,19,16,-16,-5,0,-16,-4,0,-4,17,18,
2],[12,-2,-9,4,19,-6,-20,-20,23,21,-4,16,-23,19,-12,-22,-4,-3,8,5,5,-3,22,-5,5,-2,22,-2,9,-11,-1
0,-25,-3,3,-20,-2,8,25,-5,-1,8,-23,22,-24,-1,-5,15,-9,5,8],[18,4,-1,23,-3,16,10,14,3,2,11,12,-2
1,24,10,7,-1,-9,-1,11,-10,17,9,10,7,14,15,25,15,15,22,20,20,-11,12,10,5,10,-5,-14,14,10,9,-
19,10,-2,12,-22,-17,-12],[12,21,-22,13,15,-8,-6,12,-24,-23,20,-3,-2,-5,9,-20,-20,-1,-15,20,20,
-14,8,20,-22,-13,-8,-14,10,1,11,0,9,0,1,4,-17,-18,22,9,-19,-23,-10,19,15,5,-9,11,2,-7],[-22,6,-
25,5,-13,-2,15,-18,25,-23,-7,-19,-19,-4,6,-7,21,20,4,-5,-12,17,-2,23,13,9,0,-7,-4,-10,0,10,-12,
-18,9,6,-22,21,23,8,-4,-17,22,18,13,0,8,15,-16,9],[-24,23,20,-23,17,9,4,-10,-15,16,-2,1,8,-21
,4,-22,20,14,19,2,-19,6,1,-25,13,-21,17,-11,-11,-13,-19,9,-17,-19,6,-3,22,-17,-23,6,-11,-6,20,
-2,5,14,-11,4,0,18],[-4,9,-4,-11,-10,13,1,-12,25,-2,-21,7,-22,-3,-24,0,-25,-1,5,-6,15,-10,11,25,
24,-9,1,6,-8,17,-3,21,1,-16,5,-3,-14,12,-14,-1,-6,-11,0,17,9,-7,-25,8,1,-2],[1,-8,-18,11,-5,-20,-
20,25,-20,3,17,14,11,-19,17,1,2,-16,-20,19,-22,-5,15,10,15,-4,15,15,17,-18,-6,23,22,14,-21
,-24,-16,-13,-9,-25,12,21,11,2,19,23,-20,-18,5,23],[-4,-12,-11,-9,-19,10,16,-12,-6,3,21,19,12,
6,5,0,-9,-1,-6,5,-22,-18,-19,4,-25,-23,-25,-19,17,13,7,14,0,5,23,-17,19,-22,6,-1,19,12,15,18,-
16,-1,25,4,-25,6],[7,14,-10,-1,20,13,-23,0,-14,11,14,13,10,-13,-7,-7,23,0,0,22,0,11,-5,-11,-7,
-18,-12,-12,-12,6,-1,-10,20,-1,-17,3,-14,-4,-6,-25,24,1,-2,7,-22,-10,0,-25,2,-19],[-10,-6,-21,14,
15,-9,-17,23,0,10,3,8,24,9,9,-24,-17,1,-19,5,-5,-12,-10,-17,11,-21,16,13,19,-24,-3,17,15,-25,
13,0,10,-1,20,3,17,-19,0,-2,-2,-2,-3,-18,20,15],[-22,13,6,19,0,16,6,-8,-25,22,10,23,-9,20,5,-7
,4,-14,-10,0,-13,-10,-25,2,-16,-7,3,17,-13,2,-12,10,13,19,-12,21,0,20,-2,-24,11,19,25,-24,17,
-5,24,-24,-19,-20],[25,8,-17,2,-12,-3,13,8,13,0,-4,13,-13,3,17,-8,-10,-11,19,15,-6,12,-18,-19,
2,4,-1,-18,5,-22,-16,18,-17,14,7,-22,-15,17,22,-1,8,-21,-17,-23,-17,14,-8,10,8,-25],[-17,23,2
0,-6,-23,11,13,23,13,-7,9,2,18,8,19,5,0,-18,-23,5,13,17,-2,-15,22,16,4,8,-23,-17,8,-25,-23,-9
,-19,17,16,4,13,-16,7,-25,-19,-24,15,-12,-24,2,-12,11],[16,-8,5,-22,5,-21,22,-14,-11,21,5,17,
13,-15,-17,25,7,22,-15,-4,16,3,-25,-13,0,-22,-13,-4,-20,11,-15,-22,20,-15,2,15,11,15,13,10,
16,21,-14,1,12,-4,-10,-25,25,-1],[2,11,13,-24,15,10,16,0,0,2,-23,-5,0,-11,-16,6,-20,-14,-5,-2,-
9,-19,20,8,-24,20,25,-11,18,12,-10,3,7,2,-9,-21,2,-11,-24,6,-3,-2,-21,22,14,18,-8,-14,1,-18],[
22,9,24,24,11,-5,-20,0,4,-2,23,-9,11,-17,22,24,24,-16,5,19,1,20,23,-21,11,15,-15,-19,20,16,
25,25,24,-19,-10,-17,-1,-20,-14,-16,-1,-24,-21,7,15,-19,-18,-16,-8,4],[4,10,-8,-17,8,19,24,-7,
10,-5,4,0,-16,16,-14,-23,-5,8,-20,0,-10,-7,-16,9,-11,-17,-8,-14,14,3,12,-5,10,15,12,-18,-13,-1
2,0,-19,22,0,7,18,-23,-6,20,8,-22,7],[12,2,-5,-19,-18,0,-3,10,-4,4,-14,-20,13,-1,-3,-18,-4,-6,24
,-15,7,17,16,-24,-7,0,9,9,6,-24,17,17,4,-6,24,-13,17,6,-25,22,-18,-1,12,-8,4,-11,16,-1,-7,-24],
[-20,23,4,18,16,24,21,16,21,-25,-10,-11,-22,-2,-3,6,22,-24,3,8,-21,-3,-6,23,-1,11,18,3,1,-4,1
8,-5,-19,24,-25,-18,7,18,17,10,-6,-19,13,2,2,0,8,10,-20,4],[10,24,-7,-7,12,-4,1,24,-21,-6,-5,0,
19,-16,-8,0,-25,14,21,25,4,-23,-12,-10,7,-22,-22,-17,0,3,-1,3,-15,-21,0,-8,-9,-23,1,-24,-12,10,
19,-5,22,-14,18,-2,-4,21],[-23,-7,23,10,-18,-8,-2,-24,24,-5,17,-20,-18,0,-8,8,20,16,-14,-23,8,-
23,11,18,8,0,-25,22,17,12,-22,-20,9,-3,8,-13,-25,-25,14,-20,-19,-5,23,-10,-8,22,-5,7,8,-22],[1
2,-15,2,12,-5,-5,-25,-16,0,18,-23,-25,15,0,7,6,10,-2,17,14,5,22,10,-10,3,9,20,-20,-15,5,19,1
9,0,-16,20,7,16,24,-19,-21,-22,7,-6,20,24,-23,24,6,-21,-6],[-12,0,23,-12,-13,18,-15,-15,17,-1
3,25,17,-10,2,8,-3,-10,3,10,-13,-13,-17,0,4,11,6,21,0,8,23,-14,-24,6,-18,-5,-4,12,12,0,-15,-1
0,21,-4,-9,-11,0,0,-14,25,10],[-22,-2,22,-7,-12,-14,15,-25,23,-2,7,-6,-9,12,-12,-16,-22,-18,-10,
4,-25,21,17,-13,-25,6,1,11,2,-16,8,12,6,-3,3,-10,-2,11,-6,-24,16,-21,-2,0,-21,-20,-23,-6,2,-20]
,[-21,5,25,-4,24,21,5,0,11,-24,24,21,-11,-14,1,-14,-1,-19,23,-20,24,-7,-18,-3,5,-15,22,-2,-18,-
10,20,-19,-14,-7,-24,-9,-21,11,-23,7,4,-3,4,-18,25,18,-5,-1,10,-14],[23,3,-19,0,20,-18,21,8,3,-
17,11,14,14,-16,3,-9,9,-15,25,10,-13,23,7,21,9,22,-20,18,4,22,21,-20,22,-8,-4,-15,24,0,-19,-
11,1,10,20,7,-15,-6,-10,25,24,-21],[-17,-17,-17,-10,-1,10,12,15,24,-14,-8,-13,-8,-18,2,-14,13
,-11,-4,20,11,10,-17,25,-1,25,-4,-23,13,17,0,20,2,11,15,-9,6,-3,12,-16,-14,13,-5,1,23,13,20,
11,1,-2],[-13,3,-9,21,-23,6,-25,-14,16,17,14,21,-5,8,0,22,3,-4,23,-19,17,20,-3,-15,24,-7,19,7,
-16,14,-18,6,7,-19,-21,-5,20,-20,-11,-4,-8,-6,-15,6,3,23,-11,-5,9,17],[-6,-25,-17,-15,17,20,19,
5,9,-20,21,-5,-13,-25,-20,24,15,18,-19,-23,-7,2,-14,-8,-2,-4,18,-10,6,-15,18,10,-4,9,14,-2,-1,-
1,-8,-2,10,-7,-2,21,19,4,0,-19,-14,-10],[7,-5,-15,20,-9,-9,16,-15,3,21,-21,-19,21,6,-20,12,-19,-
5,-5,15,2,14,-14,15,18,-5,-12,16,-8,-14,16,13,-21,0,16,-16,-11,0,25,15,14,19,3,15,0,-7,-22,-
6,14,6],[-12,-16,5,-20,-13,-6,-13,19,-1,12,-3,4,-6,-6,12,17,22,20,17,-20,24,1,0,-10,-21,8,1,15
,-17,0,9,16,6,16,18,-25,23,-8,19,20,21,-15,-23,-3,18,0,-15,-7,12,1],[-13,-13,-12,21,22,20,-1
1,-13,-6,-13,-20,-11,-1,16,-20,18,20,20,-5,23,-7,24,3,-12,-7,0,11,14,19,-20,3,17,0,0,22,23,2
4,4,-25,-17,-21,-14,22,16,14,0,-17,13,18,8],[18,23,24,12,-3,-10,9,24,-16,17,21,22,9,16,3,2
2,22,-12,-15,14,2,6,10,18,10,10,21,-24,17,-20,20,13,-21,10,-22,-16,19,-6,-5,-20,-24,-14,21,
-11,-22,-14,15,-1,11,17],[0,0,-16,19,-7,20,-1,8,-24,-4,-7,20,6,-17,-24,-1,14,-9,14,14,-16,7,-19
,21,8,-20,-11,3,-1,-11,-18,19,14,24,-25,2,-11,24,0,17,-1,8,-9,13,25,11,-8,23,-13,-2],[-16,16,-
7,4,0,-3,8,0,-9,-17,-4,16,-5,6,1,21,12,13,23,-24,-24,-21,10,-11,-25,12,0,0,18,8,-22,-2,4,-17,-
18,-3,3,-13,17,-17,-23,8,-5,3,-23,-4,25,23,6,11],[0,-17,22,-3,-21,7,24,18,14,-24,-21,24,0,-16,
13,5,-5,-23,25,-13,1,-2,4,10,6,22,-8,-17,-5,-7,2,-7,-19,-25,25,-13,-7,23,-23,9,1,-25,-22,18,4,1
5,-5,8,-17,5],[-22,18,17,3,11,-22,-22,-3,-21,8,18,-5,23,13,-24,23,2,23,1,7,4,-21,-13,21,-19,2,
-7,-12,-19,20,14,16,20,-19,-23,19,-19,5,-12,-8,2,-12,10,-23,-18,25,-9,6,-4,11],[-4,14,5,11,1,-
1,-20,3,-1,-16,12,-22,9,-6,18,20,-15,3,-4,22,-3,2,-20,-3,-13,-20,-13,-17,19,3,1,-8,-18,-19,-19,
3,-11,-14,5,5,24,-11,-4,25,9,3,20,8,-23,-1],[21,2,25,-20,1,24,18,-23,8,17,-5,-25,-1,10,20,3,-6
,22,-3,12,-21,8,23,-12,-16,19,22,-23,-25,0,1,-24,16,3,-2,-6,9,2,2,-3,-5,22,10,4,-5,5,-24,-20,-8,
13],[2,-14,-21,13,24,-22,-19,17,12,-14,12,1,12,-18,13,23,7,-11,-2,20,-14,-6,-25,24,0,12,-23,
-22,-15,0,-2,15,21,-1,5,6,-6,17,21,14,-1,-25,-4,-21,-2,-13,-3,-24,24,8],[16,-2,3,16,25,-21,5,-1
5,8,24,-16,22,1,10,-22,16,-4,-12,12,-7,24,8,-19,-13,-8,-4,7,22,0,11,11,0,4,21,-14,25,-14,12,-
22,-23,-12,8,23,-17,-21,-10,-8,-22,-4,-15],[-12,15,-3,0,-8,23,-7,-17,8,-17,6,24,-21,17,7,-12,7,
9,14,-21,-6,-20,-10,17,-20,0,-19,-12,-2,25,-20,-4,3,2,7,-11,25,-14,4,-21,7,16,12,-6,15,7,0,11,
-12,-16],[0,-7,23,5,6,-21,19,-15,6,9,21,-17,14,-18,-24,24,-20,17,10,-23,-17,-10,5,-19,4,-11,-
14,1,-24,21,-13,-9,12,-18,-16,-19,14,25,3,17,25,6,13,-21,-3,18,9,-25,21,15],[-19,10,-22,25,
3,-14,5,9,-3,-16,8,0,-6,-14,-15,1,-20,17,13,12,-8,-25,-19,22,-17,0,23,-5,-18,9,15,-8,11,-11,4,-
16,-3,-19,16,1,-17,-14,14,-17,-1,0,18,-1,-19,-14]]
Output: _________________________________
[[92,62,79,39,50,0,46,77,68,23,78,16,73,29,89,65,48,13,94,70,91,45,69,13,50,33,46,70,9
6,74,67,79,74,59,27,51,71,96,24,45,93,3,29,83,19,6,70,58,27,95],[30,24,3,56,3,19,38,87,
20,44,63,34,45,53,30,43,84,18,69,100,89,87,13,35,91,77,1,19,10,8,47,4,11,6,55,62,2,7,9
0,6,90,96,76,97,12,59,94,40,98,65],[37,57,55,27,36,49,6,70,18,76,32,52,41,11,43,39,46,
78,53,14,16,23,89,72,9,26,38,88,93,88,42,33,94,78,38,35,79,67,37,34,26,18,40,76,77,73
,79,29,26,94],[78,99,80,24,12,82,24,81,65,38,23,66,36,92,60,51,57,80,0,4,4,51,60,100,7
0,31,23,25,91,93,39,62,40,42,6,40,84,75,66,60,6,99,38,11,79,7,80,27,32,80],[11,98,98,6
4,60,78,75,85,16,60,32,33,64,98,65,61,94,79,3,8,91,39,84,27,11,47,64,60,73,36,95,35,9
2,4,2,16,73,47,70,90,66,2,28,96,16,43,30,33,64,52],[14,76,18,98,72,84,27,40,69,93,89,1
00,84,12,56,25,27,46,71,55,49,5,66,10,7,70,18,54,39,95,37,21,88,0,67,86,83,22,34,67,6
9,72,3,47,4,86,91,2,15,87],[46,97,58,66,83,66,100,38,86,50,9,57,93,42,24,79,90,70,27,5,
96,37,46,46,19,100,55,90,64,64,88,65,72,54,43,94,72,99,20,5,92,16,25,98,7,48,0,20,25,
39],[46,82,8,36,98,13,26,50,55,72,61,21,37,76,88,45,53,5,49,3,100,43,41,2,15,61,53,47,
77,16,19,86,45,74,13,16,5,61,11,76,53,15,41,49,97,74,95,61,19,18],[14,8,14,8,92,37,34,
70,5,48,76,99,20,26,44,6,39,7,67,80,32,93,53,97,90,34,8,17,9,35,84,20,35,51,94,49,58,1
8,20,26,81,100,92,54,14,56,24,46,75,51],[30,4,97,62,93,85,1,56,80,37,55,74,12,10,49,69
,89,88,46,5,100,68,75,39,2,73,43,74,60,37,12,77,40,8,40,13,80,34,46,31,38,42,80,82,56,
31,57,26,26,13],[55,58,37,96,72,97,13,16,47,50,73,93,41,8,76,92,15,16,73,22,6,55,37,19
,13,19,54,40,73,59,88,97,1,49,25,22,94,0,69,13,36,58,82,10,24,12,19,51,12,38],[55,21,3
3,47,94,50,89,86,93,40,61,88,66,40,75,50,57,17,65,23,65,12,49,78,40,12,14,39,47,73,20
,82,20,39,30,78,10,42,91,65,77,17,57,21,56,89,54,97,36,48],[37,62,62,99,67,11,56,41,62
,44,68,52,48,40,54,91,100,84,2,77,46,72,13,98,60,20,92,71,88,86,6,47,63,71,30,4,96,56,
84,79,94,97,31,97,4,5,21,19,80,23],[100,50,40,87,52,85,93,85,40,69,68,59,83,42,84,13,3
2,67,58,61,58,96,12,39,96,49,19,20,54,7,9,85,91,83,2,91,92,52,1,11,17,60,98,23,34,45,7
1,79,97,59],[22,75,24,78,70,5,61,7,97,86,11,65,84,39,79,96,21,63,53,71,70,98,24,38,23,
8,4,8,91,45,7,4,80,48,61,26,62,43,95,91,43,15,3,49,71,7,74,29,97,5],[53,36,21,54,71,53,2
6,73,17,99,73,71,80,61,53,51,53,34,31,37,27,65,32,7,92,96,92,16,33,80,85,96,35,62,80,
97,21,24,81,45,51,44,88,43,10,46,60,16,27,63],[19,72,1,89,39,31,49,38,53,50,39,57,20,4
0,10,68,21,76,62,8,66,48,32,65,77,11,56,10,99,73,74,100,3,25,94,50,2,2,69,79,12,79,22,
21,92,18,84,39,75,93],[22,75,49,22,63,44,68,13,55,85,94,18,91,22,36,33,56,56,80,34,24,
22,67,2,23,78,23,22,54,46,16,16,46,26,53,63,7,43,80,25,36,32,4,38,27,96,79,21,30,8],[4
2,74,19,46,33,69,1,50,91,32,10,2,18,52,33,42,0,32,74,69,32,28,43,17,9,81,67,21,40,41,4
8,74,3,97,23,69,29,59,45,70,96,11,27,45,90,12,10,22,67,75],[51,72,95,5,9,44,34,52,84,8
5,34,35,5,73,23,70,84,2,70,88,32,59,82,36,20,59,98,6,48,23,16,49,13,38,62,59,51,41,21,
67,48,42,11,17,88,16,44,42,40,25],[99,22,61,85,79,89,75,89,88,64,16,0,85,59,17,14,71,8
0,75,87,68,81,53,63,80,33,37,82,0,54,77,33,40,20,24,12,76,41,61,60,21,79,2,64,95,31,2
2,13,82,12],[5,11,46,57,35,87,66,53,4,25,96,45,32,25,53,30,22,94,73,7,98,58,66,89,43,8
6,70,70,79,3,63,73,63,77,26,30,52,83,94,64,71,62,18,71,32,59,30,34,60,51],[46,19,30,41
,16,7,55,81,39,46,36,69,11,86,20,94,44,91,47,94,41,32,0,92,59,49,68,74,72,8,44,43,66,6
7,17,89,96,51,75,7,72,0,52,50,38,87,19,20,65,17],[6,64,83,73,81,59,70,31,100,23,47,25,
56,81,99,35,80,10,13,63,31,79,13,20,56,63,86,38,58,36,12,2,2,11,38,41,68,85,87,55,41,
99,74,82,42,54,20,4,17,24],[91,28,26,50,100,56,47,33,28,11,8,50,8,31,67,61,8,80,26,35,
26,18,35,4,41,23,68,93,47,75,46,68,20,50,20,29,90,17,79,97,52,8,10,34,81,10,46,66,20,
75],[93,71,84,26,42,20,7,8,24,93,52,25,20,33,37,53,19,55,5,1,45,27,21,95,16,16,59,25,8
9,60,26,10,76,88,8,32,17,48,73,92,33,75,29,66,96,49,25,9,2,1],[16,41,20,94,71,33,18,25,
57,71,45,51,5,63,50,4,1,89,47,16,2,80,40,15,70,50,83,77,33,36,87,83,72,17,30,42,33,62,
34,11,21,58,37,63,93,55,11,23,68,82],[55,97,47,50,1,77,96,86,40,23,58,71,96,54,44,23,2
3,43,3,42,33,4,98,49,38,74,78,92,62,92,55,54,44,82,54,100,92,34,34,47,53,73,2,88,68,3
8,50,94,86,62],[5,41,82,83,22,69,84,2,93,84,32,67,9,37,15,74,6,92,50,40,50,1,67,92,74,3
3,31,56,50,14,71,100,57,1,46,27,8,54,73,65,3,17,47,96,62,37,41,3,88,35],[65,98,17,43,1
9,22,17,58,25,80,27,41,6,11,4,66,72,32,52,37,22,42,95,88,15,50,85,75,55,26,74,58,4,47,
16,22,38,62,95,75,51,23,46,89,41,77,25,55,11,14],[0,33,45,79,57,35,19,22,51,62,68,42,5
2,49,88,80,9,0,79,50,94,9,98,25,84,31,11,5,99,78,81,47,72,4,22,5,95,48,31,68,36,48,27,6
4,65,31,35,97,64,30],[75,71,16,46,70,59,15,46,71,27,80,85,18,10,39,19,89,14,82,41,25,6
,83,95,5,18,77,61,18,84,60,41,8,13,69,4,60,83,72,59,13,28,4,21,4,19,34,22,24,63],[89,24,
22,51,5,84,29,15,81,98,62,43,88,12,29,5,96,29,86,40,10,41,95,21,32,32,27,93,81,73,88,
31,5,55,63,14,67,33,40,49,45,35,82,3,42,81,82,66,42,29],[62,37,30,34,6,76,20,58,36,59,
76,53,44,8,30,73,37,10,59,66,97,48,71,28,34,86,24,72,91,4,72,17,23,36,2,64,54,77,40,4
8,2,19,40,51,89,26,50,96,95,77],[44,93,5,83,66,58,73,14,36,64,52,77,73,2,6,29,43,89,19,
11,52,76,79,66,54,72,52,98,24,20,91,88,50,50,29,48,13,51,48,87,9,83,80,75,12,88,37,54
,96,54],[27,52,85,26,60,28,47,30,34,63,95,89,57,14,15,12,21,47,1,41,48,20,41,86,94,47,
32,9,100,30,34,59,26,60,93,25,40,86,88,44,58,41,66,63,45,83,58,31,73,84],[17,16,50,18,
78,13,98,96,8,30,29,35,97,30,48,30,96,73,79,57,23,94,85,96,70,26,53,15,67,85,19,80,19
,11,43,25,19,38,97,81,91,61,19,33,48,5,77,15,73,47],[55,35,49,86,79,93,15,94,60,62,34,
8,94,5,94,20,66,60,74,0,4,91,41,75,33,82,39,88,24,93,7,21,2,29,63,32,4,20,6,20,46,14,60
,49,66,11,38,7,13,69],[20,54,25,80,51,50,45,13,92,43,27,46,19,14,34,14,17,53,37,93,24,
49,88,58,60,100,74,93,7,22,58,96,64,89,89,56,94,3,94,8,11,45,73,87,76,49,39,29,56,89],
[35,14,40,85,35,53,38,42,34,90,25,45,37,38,67,34,64,100,49,90,41,36,100,16,53,26,22,8
5,42,75,17,15,76,2,24,85,35,67,72,92,41,99,68,18,98,92,34,83,93,6],[0,19,61,84,26,24,8
2,17,8,50,39,66,84,72,97,33,85,1,65,70,25,36,15,77,67,95,1,29,7,41,26,34,42,84,74,30,5
9,8,96,86,12,95,89,14,98,75,78,72,38,10],[49,2,74,9,45,89,21,69,47,85,18,80,63,52,47,8
6,14,64,29,86,67,28,36,63,10,31,30,51,41,5,82,55,53,87,91,4,38,20,79,43,28,5,47,44,47,
81,23,22,10,19],[21,35,60,96,73,56,54,32,14,39,34,86,85,46,92,70,11,76,34,98,64,27,79,
3,43,66,66,70,61,39,17,86,93,17,22,47,64,58,89,52,58,21,44,43,23,45,83,78,95,83],[95,7
2,55,38,8,72,81,61,12,41,94,29,82,39,17,72,8,63,40,3,40,6,59,34,2,45,71,37,10,69,63,65,
54,82,91,88,68,5,43,28,84,26,99,11,85,81,0,89,53,50],[83,88,92,28,3,78,72,88,57,42,44,
1,1,81,82,72,36,45,73,24,79,53,35,76,60,44,6,89,48,92,12,38,63,75,43,2,95,63,66,38,51,
32,26,24,37,83,71,65,10,23],[8,24,54,81,78,95,22,64,20,22,30,59,4,85,9,89,82,32,67,36,
84,5,52,81,81,94,13,92,5,86,4,38,16,2,69,19,29,16,58,86,97,65,47,83,94,58,84,2,13,58],[
63,26,9,32,67,47,93,70,78,2,54,4,25,20,11,46,76,44,40,67,68,56,39,22,50,13,91,59,84,1
0,100,36,97,51,59,44,59,64,12,12,62,58,9,37,2,36,49,58,35,10],[42,72,64,14,100,25,28,6
8,60,99,19,87,53,80,77,69,26,27,55,58,97,91,9,58,84,89,89,66,2,12,56,96,37,87,5,31,17,
91,88,21,3,77,21,7,42,25,58,26,10,86],[90,78,99,82,96,97,57,98,44,50,71,51,89,32,44,95
,35,86,88,79,94,100,27,12,55,65,58,87,73,87,77,2,6,16,69,30,29,68,79,51,100,32,13,77,
96,4,11,7,57,98],[68,20,44,22,82,76,62,52,50,74,33,82,96,50,96,7,11,20,16,44,50,66,18,
100,40,11,46,13,38,62,45,23,86,30,98,41,78,18,77,64,61,40,52,18,13,88,56,23,3,81]]
Output: _________________________________
6. Arrays creator
Given two integers size and u, return the number of all the possible arrays of length
size you can create using u different integers with the condition that no more than 2
elements are repeated one after another. The elements you use do not matter, just
make sure they are different.
Example 1
Input:
size = 1, u = 3
Output: 3
Explanation:
Here, u = 3 different elements were used: 1, 2, and 3. The arrays of length size = 1
are:
[1]
[2]
[3]
Example 2
Input:
size = 3, u = 3
Output: 24
Explanation:
Note that the following arrays are not an option because the elements are repeated
sequentially more than two times.
[1,1,1]
[2,2,2]
[3,3,3]
Constraints
size
10
Output: _________________________________
size
Output: _________________________________
Please copy and paste your code