'''
#2018-06-02 June Saturday the 22 week, the 153 day SZ
LeetCode 字符串简单部分 算法 python实现
https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/5/strings/
写代码一定要先想好各种测试用例,才能够顺利通过系统的检测。
'''
'''
1 反转字符串
请编写一个函数,其功能是将输入的字符串反转过来。
示例:
输入:s = "hello"
返回:"olleh"
'''
'''
思路1:没有通过系统检测
用for循环从后往前取值,利用字符串里的【】功能,
我犯错在于碰到空字符情况输出问题
问题2 字符串很长,带有回车,官网告诉我超时,无能为力了
'''
class Solution(object):
def reverseString(self,s):
len_str = len(s)
if len_str == 0:return ''
str = ''
for i in range(len_str - 1, -1,-1):
str += s[i]
return str
my_solution = Solution()
s = '''
hello
my
girl
'''
a = my_solution.reverseString(s)
print(a)
#思路二 通过
class Solution(object):
def reverseString(self, s):
"""
:type s: str
:rtype: str
"""
s_list=list(s)#转为列表
s_list[:]=s_list[::-1]
s=''.join(s_list) #s_list是列表,把列表中的元素放入s中,中间没有空格挨着
return s
#思路三
class Solution(object):
def reverseString(self, s):
return s[::-1]
'''
2 颠倒整数
给定一个 32 位有符号整数,将整数中的数字进行反转。
示例 1:
输入: 123
输出: 321
示例 2:
输入: -123
输出: -321
示例 3:
输入: 120
输出: 21
注意:
假设我们的环境只能存储 32 位有符号整数,其数值范围是 [−231, 231 − 1]。根据这个假设,如果反转后的整数溢出,则返回 0。
'''
'''
方法1
思路:
把数字转化为字符串,然后反转,再把字符串转化为数字。输出时候注意输出值在32位的范围内
对于32位的限制,去掉一个符号位,还剩31位。所以范围是正负2的31次方之间,可以像例2一样表示0x7fff fff.
我的代码看起来比大多数代码都要简洁,心里开心,从最开始的第一道题,完全没有头绪,到现在很快做出一道题,而且比很多网友代码都要好。
'''
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if x >= 0:
str_x = str(x)
s = str_x[::-1]
return int(s) if int(s) < 2**31-1 and int(s) >-2**31 else 0 #三目运算符
else:
str_x = str(-x)
s = str_x[::-1]
return -int(s) if -int(s) < 2**31-1 and -int(s) >-2**31-1 else 0
my_solution = Solution()
s = 0
a = my_solution.reverse(s)
print(a)
'''
方法2
网友使用了取绝对值和采用符号位的方法。很巧妙呢
'''
class Solution:
# @return an integer
def reverse(self, x):
if x<0:
sign = -1
else:
sign = 1
strx=str(abs(x))
r = strx[::-1]
return sign*int(r)
#2018-06-03 June Sunday the 22 week, the 154 day SZ
'''
3 字符串中的第一个唯一字符
给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。
案例:
s = "leetcode"
返回 0.
s = "loveleetcode"
返回 2.
'''
'''
方法1:超时
#没有通过,超出时间限制:最后执行的输入: "fmjiooebgjatqjttfftvobormhubvgxpiobekkxujgvaktcewbvkdnqwqmeeaogpcgaliilvimtsqtlfnhtvvipwsesosgluwtpearpvrrlpjgppqgegejsruiwbnppnlonpsetvfverxhmtihrfcbspupgmhrqniosmosamujoxqdepvjrcnhgqmkuhrlbrwmwtldfjnnkjnvpfonuvpewusqxstgxcfikmcwcgkipootlemscowhstxcaefreafjfxtuqcbdvasncmijmvdjlwcqopxnxdwqafwugelnuwledeajbkvjilvbjkarimpesekhmoixfapihomeswgirtovrgjgarjglnjmshirxphafbghvxuwpxggpbkewemvtrrmjxscdjlfvnfuepqkjffkkmdcstaktwlwawxcpxdgxsidxmcnhhlrtpmqfafucwxdieasfjgueridmakgcehmqtehwbkvahedxscsniwpdannvbpobtskdgmpfijknlunawajfcrgvigbkrlmuonuubmaluqfsjvsajjixbqjqrvwbhebumwsjvmqovawxjqbrumpdttswmqmutdvqvvtujmkbdauckvdcfknhsrwxxaucfqhabuinedmrocivwmhtwlkvfuqjmnouvkquijisidwqoekheegfvxxvdcngjxrjtlxfcgufmcjvtxrjuhipeoenouagigobxjfcpblvirfjvtfbhdmrjpqpvsxhijumbfjehswteajcmqhcdbstolecqlktajmtrhmjddnoawocbohrjqlgckhhhrkbcwgvpxolrlhwuvebsumijspknesmsspcvibsemoccjndalknqlxguvwvhbeujhavjpflwpuexgwwmbaqmlqdilwbaixemaokwsdppqjtgkdgixhkmmoixssvatqguvqjuctwfpvpjulmuuprkobuhkasxabjxvhltaejkuxoxopojcxxnasxcnqwnqsngktxdbhpuxacxgpgfxieeubcgkulklslskdwvimqvpatdvkukejojafuvqbrpqkcbwpohesnmvgpsdqoordplnhnoacwsabsvwjbcujvrrcimqcolvnwckgfbkuuvuqmfjohxrkamlnfrmaexcqeordnwwclgsxpibbgetfwntxpbocgeguaxavmnlkbpkvdamhqlsriuqhempogbsicviftokeiowlreddnlfxvblgpcxhtgovkijdbbtjavfihmwtldogomedftgdwlkkbjlwgogjplgfqimhevlhcntxqaukoqoqoowxkntlxxkbrihahqvsrmikphqvdfrgjarngpkaptrfmufovumglkcdcjeefsmndqnrjccpqwcaiuhifbptjftksxownppntulkdqujrapdfqfxhhqssxbjophmsusfrgarnxawkjwgeqhsdgvlggvvodgwfcvvgexwgrofdsiquvuscopwoewjlkndexhgripagmggvbfswngxlpgrjxwcmtcdbmrqsrhhgchkhxntaklapsshhrdljaghmstcspinnctbkuhuukevmfcwqjgcsqjhtxnnqrsxttisubvusprxurqwnpxxatdkifxbmrnirhxghmnuixbwppcigtwusjmrddqvowawffxntxqeauojlfrebmdwrkttsqsjpiebknsvgqwdrvgbkvebqnnpeorbpwlogqssfhorkbgkukkomvnaktvhtfwkbmeumuqridupxasqacshphkippegghkprknspngnckmatxiwfhnevkvkqjhtwvvqganrsdogtswdavjtuifwfwuwmjjgknwuaowbkpwoemsbvcvalvqfqlpteqjqsqpuhewrbxacurhbtwmuexpanjajomgbhhwpmswbonkndhwubjvixmcamivcegbaqjmwoigsrhffchxrhdcmdfjmnaitohcgfvaaohnmthqkakkrfmrhaslnbbhxkwrkxvuoknvollvfnxpeemtkgmctplllsknnfxwhetmjbnkosnvjtlpeojmniwtswvxopfpmeklmfeqmgovbscpwxdktstjcuwioowhvibkqaqxirbptkhbpbiegaqllgngvbkgjsxqmrrhbuglqcmoincrgppswdjjsqrejcohbrxpqofrhspwbsqlkrgotemlfllqewnnppkrvxgbrlsbrijatuphrifkqtiltillftkdhpjkwedxihhrrdanjhfiihivgxkbenxwgxgffnexiibgltthtjslaamoemjxtwbslgfkgxulwchwjwhwnpvugmswvwiflnbwwfojtbtbnwrteumskqgskvducfhklkvmgksjjlqbtlpluljtimvxvdabdbohewgkuxxedovvarbpifibqutbhepwhtnmvqfbhugqhijuvqhhbrqtjxojpkcapsvjarqbqpqgneefkjsdoqskdnqxgnxkkwewcprbpclggpxbolqsaamwqphdttqlbidsnuhltnbpclaacpsoxdxhgmfmxgukmxdgrxrnngblqxacvljvcrlvvejebvsacmkcnjbamhkibdhgajtijbqaoalrsjufdvswkbwejxgxeioosjkpnlhpipkecjrjjmrcipqbdxmqkflqurfjghwlnrqnqnjdrqjnwtpwtgedssivnltqtwpecgudvgenwsrjuodfiuohnqdfpoocvhicrxoqakcvfjqedxuulbkgcgghhlnqesdekdockldurnapthceeoigtuanhrqshxpmvlnkkrqkqhiktnovccaindinxqphgxmqborqbdphswaemrowwgttcsqapicjscjrwedegjrcrcqpgdljpqprkrxwvcjglwihfvlvstpmktqrxuweolnamqfxevupqfarwccunchfxcrtkdfasmwsrakcscducgbrakgrwndnawjfnakvenifrigaiqgnicdfenbegujmnxjormlclvnktrbjfpojdhworurfuqtsnwravocjrmdixkdvrpbkdhleaoiujaqwackjcooalserxlnegbjwpcahqdfifmxrpmkspuoqdaptamnobemgxpggkmqcpmctkkllvbubrgmhfgucnimkmogcgxikhbquaodetfxduclvtalriwxjopgedxpigsbtkxmmswhnvwlfvkitsvhfudisjbeeuqnchgnmswujerogjfvquntepjkukhpnqkmxaswecmwnqeejxiqawodxpboetaiudiwlutgudawkbndpqdtkprwwtetahvhjekuwmchmulsqqpuvuhvxqvoadqibmuvmubmhifiuoedgfppwssoxadspiaxhchavtuhqppbtqubohxujlxosqskjsrpscwrditgpknlklbnghoefgleiqspxqnasuhradhxnqjebovnpvuvdmasaptprdtcghfgcnxeckcnacidjacbdnfquvgtpkefamvcswtdgxqoxxiouixwnalesecliwobgcilxgmoiieinmhfxwtorfahtbhigpuorsxtttresmvbtkuklkhqgvgrgwgqhmlnidsjeasukmdkjqamadsloqfcndovuffevwpmldiarixmphklwcejpnmdgaxfflbewtaoieshhxiwnxkxvwfbsfdstekcboxoujuwtuabdswxlpbivqwdwhsrkpodkfqahiuuelkwpisrahngnxwpnmswdctpojduxkhikarojsldfqrbgugnveclifsqwkaruuvkwemrkirvckkbipvnxwshxhsnsxqgvrosrouqkrvxhukwdplhltkbsjtgbisntxdjixhjqvvrthiahfilrstlxcflfowfwodvgxpvovmdiseqdinsrmmuhtrmurmgwhwxcvufsjhfegpeibbscqgurewbxavalkvidcmxvaipiliwohufnhadxuvkweqdeohgknrvhtgrmapevthbcakjxduijmgxsmfthwlfqjrlpwfqvnjqreewkkwjpbguvdnnkxqjpdcgtmravecqklhcqjaokdacfmbokocawjqqgtdwgqdleesgrxeaarmsswifblabdsttbcebrldqqagimnrfkddstcdrfhdohwuvuccjlcsxwobrldhxqcedsabmhscokhcqxsiohijxgxvceiofbgxgvxkfgtnbtcvsbttamdgsikcbimxgpgfbvqpemsvxusgftnfhjduxmqgahqcualvocswraraqdnmifpnthjiwrjlnimvgfvpttwcubfiebththkemgfeximjcnpcuotukcdavqrfugviwrnqcowxtbjowmkiocndcvksnvdogbsvjdjdopubiecmrouiuduetnchshttlumjuennoirlximstlwropaxvcupnismuvirpfkutkserxsbelxlmhqvqtathoisxfrhcohcgfcumxcquvigolfvmcncgcueommsvpvhfbpecbehlkjtutoirvmeeupshsecriubkojdrfjwrdbjhoefpnmcxminughquitsudrrtsrggnrifwxuwkglrbamekflpadsdkhposlwkdqjijgfwejhafopoexdlqtpwjcmetpwnmptoabbqcwhgwlwmnnrgqudxbdauophihnoblrpkvfssfhsfewmcqgnvrjmotjajnldxrgxfwnqukbsjdlewaawqtfxckfcswrjcepskchjmechqilcbpsnafhjasutjcoarkfhqmkwsvrqkvpvngncnagkqnfvirtbueawgdxwglhvhaonrfjfxektcbbpgkxtscxiwonkipdgqjjcnenhxjmdwpassgdonlkuhwfiqbgutsqvrkkhdpmtuhrngnwcurkcbdwspbpobscnfjpnenrjvqnqjpbaxkpstnradwxetiadrxnktumphldmdulxppavxmgrvjwhxnronnmnweuntrehmuvicigcmxmfoklwhjworllwxvsjkaaumghbbvickieemjhbreglwilgexgnsrwqdlamefhecfnprgbrhncoswtuhrpjflgvrdrrustacgauersnavjggtdahngdkijkpwroxctglfmwmbbftvnldiftmbcnjgxhtlbnhophnbkslppccdtoafpmfgewjwpfweqokoasjjskqtekupvgmcjluldpuaclbhppsrwpvwtftfpqrtllrouqqkixruqrknwcgbiptiweenjrbvuogsqujjsgariqdwupvehbrxswtcjpuojosoewakcejqsxdbrejdlvbkalivartpclpcipltisekhoraxtbolmslhldofievwvuwgvdelpbvhwhjtdfmxvdaapufrkqdnnbsedqhemrjbwmfivnpiqwstwekurpxikoncotccpcqggiumxjngfkbpjjefncdpntirishglfafgtvpurxinpeeounumhfbvqtqixuxfdkxhvksbvnhpnvdpwdkaighkwgagqrwpcwlagbvighsumsuuvpxrtnautrbdpasamescodhakestmuwdlaknkunuqdsgcavaaeumnirrkwxuwdcwhimwubobgvehdamxfnqolqcextqpqximivndjvkltxwgjrjwvbhqbllqhefndppwaqevaiblbrjeulenhoqtnilfebhvqfhlwjbltsfigdvieweslfuoaadefjoxvxbtsqnvjdtkmnjljjshjfkjldtmrgrmegnxmnitccokcgfetwwtjqdfebcvkgjdlbkfmpbogqmpppslclhxtexjfkiixcwumsbicqbfoffbnaaqwrvrxcnfvnhdikxavpjvgopbajkitjwuxpruvcocmtmrnfmgaktoqbujfetfrbfgghtnfurhbespwvgwejhsrlqnfnpphkmgrxswxaxmwixplqvrreurxtsnbwwpnkufbbxwevpbshlimhifhfcutqskxncmmsfkxlsnsmcpvaxsbkavgdssotstrtqgsswgrgkutnhvpflwsruoonudwmhivplvqbihbrpkfapmqeodilvcxmpandesntrcorkhwocxcfckbwqsbccarauikphpifcunaevhtdujdxkqsdrxmnavattusisowpdtpikwjjqrthrgkncqkddbglkvsqqogaqcgmfcqftmvjrduwnwegagameuaodcnecivaodawvrjgbqrpqprwhfxprbuucbdurptffbafxixvrtrhfndkjedujmfhgthxwgbtdmsrijhpcgeatpidnfmkvnnjwisoifxbpeulreaudisxlnbrlxcceukckjuahtnhsbhdbjttmaswuwokmrulprnssmnotklhtudiqqamnqgvoeojxntwfmwqhcnafbjgstxdwshihheecgluuspdwnueqdlnuaohppndmfxxkvejwmdeeiijsnrpniaobitidjtrrccrmsqhehpqfhoqcsljxpvkdhqrvxcensoexopemvxbshacfgljvkhccovtftkvjtmdcriqnxtgiipedxjqxhbnwvsgutcmuxuuwlunpfcqbsmbnhvnwikeinwjrjmawevxjedqkqwounmwkuobrerphmkfmewrqebwnmvuhwnbjrsokigtithvtdobvtjjrgwgsujwfrqjrxnxnkdmmumovlkgnqnvrknkwcrrmxhflnmjucoutjidutgemccaqpgxuptlnsjohninpaxcqbluikkkabxqpxrareamxratgfbdeefgimeqscvqdfwfgjntgaavkdkfphxsvoscnkeqbcihewfadveqeckoocadsrjdbgmtwelmfsdxlvvjquuqtuiguvcganrvqmmmlartokohbiwhumwlrnaoeuhgakfbticdnponnkiafixkxgcqqutnuxjkkawxrcwqlrbljkdrancucchqxtjugwwlpxewldxugplntsndiqvkebxcxbklrrxioxwghbwxupmkjchwxhbxfjqpxwfrfqmshiwrxgeqhdmlgcbjveorwudpxsdolunasssudagaxblxpsceawtaoiibxfutsdjdavdcjrhgkljpwlercesvfxwvqqaitossibralpwtcqntctffsabimhhebrpmewogkwmjbmcwoaqkdmglbjbassbglbjipjoxpvltbheihlkfcehjwxcwhxvcebvemjcugeawviebualtgfipbkmrugtrgxuhbvrwaurtupkafbcmhfqolcpkahttjnojimfelgpkpmwwknjcowaospcjlceodrtdqiuhbjbsvhhkmfotbhrwrrovvphvoflvsaxwrurewqwncxchlaigfqdghwnwkxfwvuokmbvqkplwvenxbbaiiernihucfrsxjurtjxxekuowuehdvcabrvxkbkuqbcshgixqqvfdvppmpqpsolpmamheqahjvcnpvirscnptdrvcwwwmvuwpoxxexxtekbtxvuhqwopfvicfshulqnfkkaqjwibsxxlgpmblmalikfuxceresomwevkmterkmmxmkaxkedfesreiwufciqttniffastvbankgjjwhqtlgtjhpoplmrrieiqdnbxlhtwadnwwenwdfsnntejhnkxwrmmpilulfnsvcgpdmtnmhagkfnbhduwengbatxmwdhaskcunnskxfunncrilpvdlwvxpnundkxjhddftjtldookoepokahrshbotxeidbhwcwpjwqmbcsvvwcjknwrhcfkovigmvanvgcicnqpejblwffootjkmdcawuqcdsilwrxngjtcusmpecmpivkejefdhrhatcqplungwrjpbvcsbopcjcrwwoxljeoaneadkoncsoavkceclqgqblmilawqeeutrqjovqglsaktqqjqkrkrpqvkxdulassphqcqkjrqvwodlhreabkovilmuwbkmnofprtqskvrejnetqmhupgnrmpwaktojgkfawvaeksxpiwoallpfdxpmdxauxmqhmoqtfgpccaagebjjpfnmpmnoovcaumxwijmiwjvccqfrmofpnccjifgxmrndjrsgbsdpkdlnjbgqrockelfmbdjogkpxindojmeirwptidmkkqbsfxfupvivuircwaranegckbkuwxvaanahxgulvtkkftmnoalshutwommheudstlqadrrhbwhgrewqohlfhmcvmawgbseicekpjgtrduojrkrdoeqimslmvmoxgskrgamkaqmjeijkfnenxqsvpaowqigdlduxgvisamdomhhlefghjcrsindkgnucpnjatvupleakctrchdjslsfaoskposkttrdvuakiwxlthdnagpmtniwpjvtoshwagobosmaxeovktpufaphnjvfhcqwhxvshbudlvlisdpupuagqnvspuqaajldkhlvjddjdmebsturbfnelgavabrqjnvdokjhgfelhialpfvusepeuljqrojgdxgmnphiwowbhawgqbiwqcexelodsdpqohwpfpwaahcldfgspgpvmwgwlxrpdrdakegfxkfhgiwclwaxkvkdwqnqbxckeaguxofelpfnoqnehmnncfhowkhmvbivmppweglwiwvkjaekgomephiatkoujaljepgvdmjkijfwohffjfgvrkvahqrptslefhejsxgpbfvcxopdirrohpewqfrnuqriuqqjsacxmmoucesgljpasghbxjvwtjudurkxsovrrohwqsonrgiedwvtetnbswmhetckukavadqobqupmhkiapxlwtbrpwbldojkwlstissgvnuwsvpwrterhlktukmgkboircudtdmeururmpxnapmvnapqhbvkbnskvpfnppwkvwoikgimdoxabvrqjucwartrcbvbvgbhrjbdukuvtowidqwtblfkowunijuifxttbnocrckhahqwljbcjnvgvtkpogdawthfcamfcxlcksvkqbhtxccctrxfnrrksjshxktupqgobpgndqkimunhjakrgjwxhcwapmdxawdlefcfnfjpaivdhhtjoplvogkabgnwvacrfvjedrukdjlhmwdhatpghuxqohqkoheqcgmiadtxufntchqblesqrudgwiurkkaiejcldmhqeugaphfrwcfvgxatbakfskprsfluddqmmxteurpwshxeuvwhgarmgphmodqsrbmlkgfrbcqapiinevedpxrqwilxgtqhfovfwivvgvppfiqiwikncwlhbgaetetsprkssolscqndlfimsvixifotbqajfhblptucuxvholrukxptxfhxrtctuxjimddkedcnwuvmdadcthgvgiopeiaplcwxxrqhhcelomcawedvenuaannwdwhgwsuqqqjsahkueanvkssvnqbflfmlespsnpvkvbnmpdvicavsgpptaafephuaahqkpijfxlelmveaxdkhrwsvdxrfwmeuhddovgwjwhwigghskkmnuvueqkmbwlvpawxhhiwncvmehgxaeuucxmubveoobvwbnbvdvhqtkmfvfetinkrhsuccstiwvrxsueltpsfdhfbnjjlmmtmevvprbxrpkaqkwgdhfkltrhrkseistitchokvrjbtckkbdhfqowemqlmwsoreijixbqtvjrjbloeidbxudxaomakahhgbevdmmkttsoaihfxnwklfufwsmxuxlvirpucsffrwubgkuojjdkjjjpowcaivednubphahifwxjmolcentspcbwalesbjcxqskwcnjuxdkxbudqihgrphgrnklomdxsotrrrlcbivhdfuoblbujrxwjubhdttrljhhgobtghmmeigsfhbfpducvncpkfjktageqqhmefacktcideranxvkoquektfabdqafqvncjkaonaqtaqwducwuwxhulqtgdvtfvdfrtiqqgicxfopqdlfoxkgxxqncxgmbpbwqddrhhdguktlfcaqnbxkepwfuqrfrgpgasekephlfiwssurxqwfsdstkmmauedvgrpjmghwciojtwogkaneqdanflvjctvlgkkupgnwlvmeqrkqjuhesfjwgjdwoofbntmtkmdjoncfxnxfensnjawunvunsljivweqppbntqbnrhnwccqivvvrbqcaundwuikkuanejvauvsnuuujlodbmucewvcdvdugbsornreqsvtgvktupdthumstpfdplcpjmrkupmxhqhnqlegbvfvjtcqodmhbkbulvjdpehuhengmfjwiteqgignnkkpjqhjcdrcbtflqafwjclkkdivpdxjamwcnxngawlwkmvvacxghmilwtjllmhdqrrrpguvuwvakhwrbevwhsriufxdklummbldgvjlgeaqcerqcfvnxeokfqjmuqplvmmjdehcpounjuwkeubmccxjhdapktarjcudftvsoviaifvwothkfedmfiemdfwwcesaekstekwifaffijqicsdumonkiuljaqaairpmpluwkoiglwtoiuhagntbxsnkcqmvsqunrbtjpvmcfksthcxrkfnccnfdisxfrpjpcvdssgsrjndhqmlobgevrodbkqqawxokawlqfkskmphdkltqjijbkopxiarxxocvndvnqiuvqaopwngwvdbxxurtduibgvwriopgrphdmjiccenrkippphqfddwhtftnkwcvkjemiimfqoabsncqtbnwovljuuocctgslndpnwmaanxfmdjkcjanocxgdekpqnleklunsmgkqpjoqdvwehbmkscxieovnuqeblxgxadtkoidhtgusdhatvdtrtrmhqxkxvtrvmtmfrsvafmdknmextdlidmtbjwffjcwlgvfkiqttqoehvgfjmspedpdaxwvjxcoralvqskobtowotoooiqwgdslospdvpubqbdnpjqwiqkkjpufapvandumscahjbiopjguimjktodixkqsociortpveqlqegvogqmljlotpnbxqkbgipsislbxvkgxwenqngnsmxxawflpniijxaefjddceskuxmovflaabgecpwtjnvockldoflnvrgpoixbevponxjnqdaxvqpqsjkcshugqvifvilggwsqsoisdbtaspqrqftikveiehplkxkutpethwukkrxwjbpafnqmobubbxcsfwtncivklalgwdvbcoluiraxnlvkxwdcntnxmrouptxgxqtiehookjtjhrfdukjtdjstatfacpwkmxcfxtpwlwrswvgmdgufwfjbhvlhfvsbwqtwmsoukicbhhxespuahrsjqxbrqucfuemututiqfwavnhujprlnmvsukfgcefmhspgdswbuxvvvbinsvdhjhcgtfboenfhgskovlhqxfprkcrfkssmtbrtuiuanijgsvhkiqwfixumsrsudmocccccievfwvrrdsvenxliqoegnnlmnnqapcwsgaovwcnxqjmculpjwrigfomtivwijkdvwmoawbvjkseumbihljwfhuvstccqrjkjcafwvbrpiovufdhexuitvigjggsrwxmiandpekrjtmhjjqvojmeqxbqakjatjvpiiciklnwxknksnqqgkauenpjpxbcgkcvrliuabbojoigquesdrrxpwtkvuisrqgufjwhjhpkoovltttkphgmqsueekoxvdcgkbmkfmntxlerkvnhitxfaktvcqjadnfkcmctljfxmnwrxistawfjpgwxhhtpilxqljjtvvhqntcjaetnnixqnnpivgllpaaqgbitjjbvboqlocpfxafsjqnclosupkjsclpjqvffsnbnrkxtqxppforuixhshjjojihhjqkkgjujjtcxwuwppqcvnicfqobebqhuwdrtwrbngoirlqbsavixkklfcraedchhgnjaswrlhcjrfkbiiourpeltnbwoxgpcaxkrsadkfqohvlmkwtndlhrfrotsvnimniegfgpcqigusdeguldficfmnkqanxkvnjaheafcajcgwrbfqxwhmoijkkubgmtvxjfmhiwevlaohfrqlwprqdrsijxlbsvenrmngdrhgicfoagfnjnmmiirxfkqoupsnbekjmhmufablcqgwhagpvwehweovakxiqvmibhrpnqegcnkvrrqdtsfxffpgwelgxhrkkjxhfumorhaeoplwsmdjsosqqhopftdaangeqddvxosbhtvrbngluggndljltaqsdewgugijlqhnudambmoouffdsxcjiosisnqubellnxpaubchcbsrruwcslcsvohrwikpjfudoscrqunbtumwurbuwxsgchrpwgwxbctagsasxvategttvxwqmeqnorpatgcmtrqeevbrctdogwqjltnvuqwwrurnmianhvtnjwvhbovqrfrqgxguxgdtfrowknpufdmuecuutxibubpihcbnndxkxxadvehhtfdbgtppquldinkroehqfjjmkxwtunxpesalpimkrioevodccwwmixtruaihpibeocuuormdoajnkwaeehplvwernsxhqgufswnklxilownwxmdplittvvedonbduwampvvwajgcsjixnislihqvietrpcxdgbnhvhsakxaibbdaudpqdwibnljrpirxuwlhonwiekfemxhqdtavtnrxethuppqowvlmqgxotrmalkcjtlxejsvggttrgasbvgtotkpbsexknkvjtadtmptxteocncjqjsuuqsnshlvlcibimuutfdtscurvdvddbqhipvjbshwdetvafoctdpexmnstjscrgqkapttwnpcjqtiahpnvxciwrhkupanuplhniudqfejhrruxkgfhaewghaciuptkfamgebjrunltumqoflcthfgjbkjhaqwehhdfabnpccqgueenjoehmojvvvoqeknsgrlihnhthdiaxcaevildgofleptnivaucftihepfbbeqnmuckqajgoddfsheurxrcdnfaofvttsqivajxojxdudejfkvgpcswmixttskdbdgfsehntphgkoahbecrgjxawmgiuufseadonqvdwlxgqcnavvclpmqfmjjganhhdxhtvuttxdhmebelbvevamvqlhsghlwtockesqakxjraajnjfejwmxwhnohhcasvgqlinvgsvemreuxcscjwqgscrorcicngkqepvjldrdxpgiefpxmpgscchipojtffkutccgaemidtaxkleubxvjwpqctmfsllhtbjnkvgfsqfrikdspkovnoqdntuvppiavvdfxkjurguklmoqjnvhfjgasafrkjtnsjrklournejsaadplldrqbaqxspxlregclsvqchvodmrpftfuujgampkwrubsofennxthemeaavoulxhtelkwgfjoxrtwlnhkcliqhvjvloddcwekeocnofjwskbfmdlfxwfhiofcabsdihjsanhwqsskdbfhjjtemkdmfjfxpfndmtnmaxijluerkwxwqggcrvkpxmllbejdisbhmfvphlqmqaiksjvmwqqjpjxgeuretufdmpawmxgbdbijqtxmldardorajplefiqqqforshnsmpwfqmfrioihnmacjdxgoxshaxkvrmohmtdomewlnrbedkmdtaghgbnxvfcmbwiwkfwcdkltllcppcwdoaaroogqvgwvcnmjfeqlmhlaaoeaqcotesudewilslhqujraxrajrepkoawxwllbensnbrqxkunoajirxfpsjxhctjbvingafcmagormhjpgepbgfwvqeqkpjlukqiwfbbitbwrtproacjdgqujscbrrxfimftushjogmritmwrfaawscjujtalbeovnpipgxmpcvxhevwbequerstvdhgrgchkegnikjicgoqoxkcvnquctjendwmdiqiabldxvvorcvtelkkwjcklivclwqxaxgjgvustxegbxmrcahouxfefrhoiwosamurfxsjnaeameckhgqnwxblivhplkwdmwksuiocmjwukrxguwvaesoxfuohncjmegisegotrjcbkwdfjhppqhmxmhkuwxatplwcuttvlabanuggfkesxolvufmxfqjjofucgpoqlxbblkidqvnbuxdhwovqlvgnaedrhqolrfmmlbrklscevluwrttxhhwrorbbjqkimsrbfabuojuckrwkgdqdcfitadxqewunmxhplxibqaruurjtugtwmxgmvsgphddtdlaqcgpakjtkdmgimfewunpmfpuwdwhkgwlsmgucmuiewrtsoxsekaltcrdfixqcqaigbobqnhkjorjkjmpqhpcjrqctfhochshlbwmifmqdcsbvwmkrllevnfajcmjmtdalthxcfdbqtgswuqljvlbamxhiijbgvulmhiaqncprimleupkwwxjkwwowpdgjnuipgrjqedjocnwgvkabfhutucntoeinkdpuilbedvhpjisnqitctuttwuebwlxjerilmmikjrrtunxbubmqqnerdllooaexvpttlxftpfxdtvuckvlfdcaxdakdpmnfseromrcoemjhixtqsvbhmmalasjabouewqqcamwnstxxiddstqmhmkkgxjjflohmxesihxjggmslwjekgwgnleahtnqkgvamnhfialmksgilacxosqvjjdbqshpgjsowjjtclgnrwbsgofchqfttmwupegpdfniadldnjlfdrobfrlwuhnpcpflfcsghbpadkemskhuheedijslpabjxibfsumwcwgvphmirvmtxotspvmsgdpikhrcwbdfodvhmbuwcdbajqunjojbsxkwlnfsbkhfkjbosbkwnlgfosgtqthktnhskcffsgjffamsihrarwuqwlrwcfqdjuquofslkoiuqxvthkgeqectiegfadmotfueqplujbmelxvbhsdsqeaewmdqsgrkdxmdqprqxqveohkuaixkcpwvoelxaobghlgxgwsaetmuiawfjmkvwevfbtlsjctmqaejsuashbqmdrjcenvrlmvuxknrgkalwpwjdalardkmvdrnxmxplgukiqquhqptaqkqttbilqjuxfqelqjiuluhdomduraeassuqmuucbvvbqgrisjshselrmcgnilwmggxdlekbfwnsejcwcbhemegdjbgcdrjnduxtshmxfnfmqtjuhrnkrvaxwkrscbwlkowchhqtajovvmftshwdqoknsliwoedoledokdawikgwkcflcfbfsqcpoouwparnmmnaeulacbxxaxteasojobrtjtecuxjsiawqfjjrivpqpkgotpehvtikuqxjgrblnxvwuccjkwaqouwrmdvxgonuxppnuutrmcksjighhnbjvudekwiqcakjjxtepsvmeavtgjvmirsjnkfigivmrtvjdbchodbdwbwsihxivkcbgonnasvrshitmeowsnvhjnvhkcvdvatiprjlplwansciuqgrtstbgftkkbffameqbsssuebqewlrvwkhqjsxfqodieanhfnxtrqbwlotmccdnecrbtsjvwprvdxucuoowxurosopqpjruvhhixlroahgrxakqaancdmslrhgwehclwxrsnfojneilhnpkbbugncuowtgwbensblhcfqxgwqimtulhxcttoexhdqpjobtinljgiefurjotmpwqlubivecnqithuemwsqoonrauirjrrvhvenqnkjxatjbpcgqlbqhtvipgshkvsvpvcgoegtejofarjpgijvmnoxubakcahbgjwqudaskaqlbxpqiukvvdchnfruxkrieahkbsqviucduowpmifsrwrrttfmjsxcacfthcogiglvargotejtsnrlotnssrcpebrfultfqgtjxondnxwpgjupoepoqojpolshrmgirllhhvvabjeqwrkuthfivsushiargniilnjxbhvubuuvkorbulpixedjhbttlipvggpjfegwlvogkidacbmxhfhcwgumxtwxktnfllxaipitngxinrmleupgdokxugspwocmlfibaqumeiwjvspnqcdwxrwbiknlthwuejkjkqjrhihtcewwjhuqcjxdmggvbobhxquaqqxsodswtiiuacrgulnfidvtasedusgoiqhqbmhcrgnbnmcofsqpdjdpqlokdgqltpqrijhhfnwdieqsembshhgpachkeutxjotwksrfuokmqlsrdbpusojvchivonwdsugiaigurjrlhaakickpfframrpstjjvgctvsleflvmpludhmhtjifiaprhqbpnouxsxqsfgrcscvpcphxrelonfsovrjqjxnubvjorrmbdtfqfsilegnpbhpbtesuvobqkghoomekhscquajcfrqaloerajoccnqfumidwrbmphogirqnsekslkcpnidcpskqiofmjwcakkxlanwlgxenbljdjjkvmpglnuwcvnrvjtogfftnoknigbbeendtcdnotolnuneesstqvhgdmfhurfctwkwdqgxrkulefguvxiwrkubmhaiiknlparlwgqmsdohprabpalgqefkjilbncsvbjtbtvqeenuxqxtckuumvrqcbvwclqnbirgbdtqofbgdmphbituirdhbvrjlbuuevrttfkamfoudocemwvbsecqxmreeqxjraidhkcomgexhuosehlvsfufthhiupidgawvnkcdxntfwgfbbidpafdnxwcdvgpbvfeaeusxenexbvhbdmqwtmwhjakhvhfnerrovjscvtggibdlrbhmubofsfqknibomjnoqqlvqkrjtrbffhcatucwcotgerdevaqqvkmoxiwxrfjafpikagccidlcullxgelmugnpafukehmnkrskdphbotjnlwshavfsvvpwdsdbsnbdlepqdgxdsplrcjpemupcpprvcxldmparsjxmrumivxenjmlwijietdttdlvskgbjvxsgfqgrhkrjibngmtaqrcopqhavesvsghjohlmexqmngnvkcshobdrdpkvmrsuddbtfhnwcpkubvtdliiwpcwmobflhkwuwuujrufumvakvdrqkacebgnpqnikphpxktqbtalxqcjmrrhlnilrndwdrvscsinepwxvmbbgiwwmfhomwabomkjxbxtervauvpwfsaubcbgcsmwmlsesedpeqmexeghffuqphmpbiscvgsgkgvvvxfijweflmksjfodfkxxvblsnkhpowieqmklompnjxssqgmxgcpxnukncxmiqtuqcciblquvqpohjqiftrfnblquvlrsbujcttqjrdfvqcwammamtorjcnmgfaovjtxregcmxgiessrnbivoordvpcqlcvsqwhfwldwjvxwknojirwxqnstgbskvubptcifjtcljmqpibvehluoewrawpnmceotheofjjtdedhkwpjtkpmcsmgdnrtmkstheuswoxgejsgjdgrgcfvksmjutxnlgmikrtkxjulpikucaonnoggpkaclpcjigmvwpqpksiltsrjomxfhikbjnhcirbqfbrsbvukgiemkpkfnicbnnpfqbjxdcmtqhexeunbsuxhspkiheojixhsuphslkeqcktehuvnpncvfqlstpufvobiewimrqqrthqkceuhvmlmjfutsbcwhcoproulnnqudjlhnuiwdjmoomglnllcfruptjurhinljwtexodrddubwfxkjnusgowrcvhfoswvwwacshesltmhasjijgxxtpjlgcnolstrlcspeceimidxtquwmpdhmnhwpjhgxbvjgccvwvctwtjrikxcriaurxhtukmmqxluxnxspiwtjdxfhncvraxvcvjqoueqgtvsiubijujiubukqevquhojwrwpfpxstvldpoaocjbkruasknbrsgqkwbnwjvokvxgpwentlojboflvgauslnkxcvoprlaqwwnwlfajetwvmmorvwjkwdwqcgsihuwmmnjrocxpnkcotaapehviurtfodhljwwwikigjlunvieekkcpgskwfgcgfgqpirlorvmglpgdgquitrkjcahljtslamsmeokvrhvktpgroalaewsopqvpqhteippsmnvroqrackspoaqwoqkmotdcbtnjsporsfdurpkkqjmgordajainxrreoxbsjuabexmekfaomduuflvqegoxcbxfncgiumustsjljrrgqbqcnvfnjrmmptwvpfejkkcupxbpnmhjsddjmqtgojilvafveheguuciqvmkqfbhlacptlinehedoavlljfislnevvclqvixdihoshsbllpwiseqnspwewkbxxucgudlsuiujtmsluktehmvldthcfjipkshkbscqeqdhatatdmcbpnituintsdhdgcklnveepmswortfavlbqvdvmwhqtxatnotlhnrpogreevlhcfwkvgvtmoujancbuncaircbrnxslaqcbnlfuqvudxwwswmloxhdpcfkhsohcqkohmckgrfpkrexijqsjfcenplcimvnkxkcrtmjslevieglegvovwltjiuanlescfgqrbhkrncggbmtdndhlldxvfrwoxdxlqawpguucihrlxhippcvdkargxqccrdevsgvtsuaodlqahnxadcpmfejwnlfsqcrxdcnmgvomwornxpdwslxpenxnhqwgvjobrkwkjbgfrqvbrndxtvtlvnlsgbhmoakvoqhotgijvjmnfqoowaurkcfgavopvipisdbqewdpbjgqbofjtmradwmbqeufkplftcupvaiivrtdpjqbdkuroajstvrhtphstxquomhtsxsvphpffilenaerdcnuchspjbfwvbqjhuehxssfbihipgvphcqnhgovgilgmrtjfjjbbbadqiivnsuuivbbaobubejlctaucmjcflsnrkwvwuihvlrbxgetcfigqxokqhtsrkqteubgkecbofqudohsbmqhmfwcojjdhvkgkaaajssjljwtnfslpprvbwaunsrcguafsnmumoaqvilwmfmldpcjmiesmbmchpjsutnjcimwtcwuigpvfmncpebjlicbiowkikditjnkfijnrojxwxarjdjudwlxerqxpjwjahvumiclagljnoufktsrkdwnqqmbqcvlaucohmkumovesdrhlgfitpfdgunqufrxdwnfwkqawogqwuhpdccklcwintkskqkusxfesmgquxquidnucbihevkvfgkscealufuikbcdqxrrqhmobrrofwirpwogmjldjkiuwjfkkakohinhpelpowsfkjohrqkfkfkwpdhfiqteuovmebxeqggigbkuiphjgosodbaduruchapqqanlseftevsfrxigfviffkivorejiikjmbnumjhwlunefjgnxrmdkogcekfrqonphmoixguatiugddrvfmnhmvtlidvbwijtkjkossmbnqpwlxapwwmkcahpjenctxwfuaxinmwdxeocouvslfkumnkhinudnluuvjgljoulmmrclcohdsedlfeduwefxutivuwrfhemjaphcaunovvsoamkvxdhwtctncjsjxouqabrdixvmpmhwhtnlqdsegckmjffnwulquqxhjghwoqdjakthbsoqhdickmtcufkcmjcftlsdlcnjvofqciscmnlqwumhjajuiprgwuhdhsnoeckxdpothalndwxffgxabrvrkknhrivghndcvnmjwlbrlbetahuwvggwannoildtnoalwebxtqnffxvrkdcmnxdvonoionxugoacqcisvnoarwphmjxmcempfjjwseccjvtvbawmudvkoxegudlwtfddgcwoubuuqdtgtfgmqrbegsenlxhihkfjxqmldlmssxvfnlolbrteqpxmswseaknsstucjucuxtuqwqgihjlvenueiawjnganfdvvfdadxvvbivqlskiusflemmiqfwrskaqdpxtwtwdhcsjmkeclcqvuaukakkwcabefqbooroetepeuxxcbmlsftgejlchuwpcbwjpccniegdgkcdqgrbbwutfeaffqosjrkwococjsaqcgrxdlxjdpntopjmaxxkcnuseowwevsuorfmmpxkxanohnpahxrhftfljhajtweakchcctkngcedhdiotduqjndcuegtguoupjfbgvocqestolfjlqqxptixovhefirpvxjjapvjmphooegaqqvkodkkgtcmpqdlldcjpigksjeuuguksctjpxdkfmjkugvocfxlmbqelvpftkfiiwloshcbcllhvsirrgcfwrvjpqrjahtcsnlqorpngnqdckkejfkagiuxnmlxwfeqkguglhjpbuxwsivprkpltpfxgatadnskfjhrkichcxspwuqbknjqwvairedexgupghkrdnrmcxaivesemhafwcnuhjrddibqcphgnvoiidchisfwghemugurawxfhtlvejfhbqbrflgfgniajgnkqcnqddtjkibgsolowgtiapvkagtbudukrvqjbahqnpddmfdrvacncaxfwuotaghtqifebgckhwrdlgurgfhqsvfiphjmmpxeururunmxjptxxswoavcirwvruhmwjhvxocoxjdfhdjbixxbptbmoheajevphxfhcndrhjcfreedduafgqqdctwxqiadhnjxnkkprdrexebctvssjpkbuwujgpbwalulsfronibcxuhmxtpijhamexhnskobatvnanqadiixkupkgowhwrrwshwvoarvjkemwsfuckqdhdpvrnxiinngvnbaqscajlrqfvkbdprhasjlqitrgsneocbwjixmbdninowrwgjbljnotjblsqapvouwjbkpifaowecldislkxrvcvjpciwrsqvkpwkdaxqjxivxcuutteppmpedxcprvbbrngqxhjpjjcxnldndorggcubbinehnqkercdkgnuhnbqnvfxjngpbexahxkedtoprustofiprrvjhrbchgsbiswcpciavxcirwfbsmurinijthxumlwmdmjwadqhgjvguwlegsbjedpjsxbxacjqsrbesikjurxitwfmcrpaoreasieccuewnconnjvoiohhuedrwxnuerhweuloeihnuixarajhdsfbiruukndhpbidrrukvirgpivfwexdddsiafrupdcbaswaxahwfkciovpmuexskswudqrjlacawdbmqrfcnhllcowwljivwgidirfehwsgqwkpktoptpuxjsckddltjrjpjcfmedlsqjjbhiruicunukcaejqukrjxfjicaaufnfftwwocmxuemgwbhngbaxpmmpoufvwwhkpnxwhpqieeaoiuknnifddngmrejsafwawnjajvctsgxcnkxcoeqfokkhojggltcwtfoepeubbjdjibembsbvqtdcietlhwlwvmvrxsucpvtuwtttvmacqbolmuahtbjwftwrjrenvsgdshshtbfoxdelvredabmpdicsorsekrwgkodhkkqpmcnkjmjgfiurogxfwqinhjcnwhfmtncvqmrxamoktfktpkgcqqfjllcpxcaggujkleruublfjaupnopqfibqhogffilfcpofehdpktibqstljbtaubucckxqpqarpncflhqredwmikaasdadgcgofxdfosgjpgldkdjssitwqqjojnipdtxfiglprowwxstpwdvsekqrqnqmwobfkmxqkwhnjngacrqjcxdabcndraumagvulwovmpiwogphveeaminwbxlglruepgcwhqnmfcedxsblttggewckvraqorcfvnkbgsshwgvmepmesunrlxsnfrokqonpxlmwxfgeotbbppjjcrlkqfnoagmdutvsiaanlicewsssfsolubhavplhpajfankfovwwclupokxorwfsqnjnxwmwbaxwuoesjjgqdhwfvtpwqfugnmriarafhvfpkvdpkfiuwtowewucvhngugxaiihsqxdqplpnbaudexwrkcfcocxuudlwplbnvxqrfgimfsstnmfpqpsgdqswwewkmtgqwtojuqpdgdseqbtanvtvfinvsaotxphccousmrceoenqogpekfqiutkrhaulbxkkkvlkuxlncujnoedlwobahqarncracmjbvsbkumqxntqmrbgncrocphhxoqtdbnshumxkfatkvcqvwaibouabtihbpkmexkhmglvrxrsncalawgcirsnumeiadwsddmoxeiurbbpcnvxfjfcceqgkksteawxxwsbrfssimqrhokwdgurpwieeudovgjbspexdkjjhpuxfuoxmwthgqrfskfckoqkcplildwxolxdeabrwitfjrddmosinpsbqofejhqwvximebmgcnlbwcxncncoethoulfdxhputuqsfavvhulfwttclkdoahqbngqfdsmlsconofhgpguhblseasxgavlsnrqkwbwcaqcvaxhjalfbokrcbqwqofdjksucbefrohmdlopgdkwkpssewkodixnwnbuvrkkidonvxtwgieirsamcparwqbtjopjdbttpbomudwuxxisaqxqellodugmdvdkfxilwwgjqrgccawmwrnnstdorueikrgqrfrxnuhvkpehhcagtmcleipqqsmqpdabjjvjejjhiwhexwmbxlxksxieiuvlllihlmfadnlxuwqxiecesemlmdvcreprejxkrvaekkvgfxxceelieqifttxdtaudefuijghocoalkilecopenxmanwwogbcikhalffkfjdmgvkforjnqojhvtfbmlwjinwkcmdqrbxqinfexdwgenwslwaitqrkepttwoijtqtfisjbhpvrjdfecvhmfgivtholodmhkqwtguglxvopgbhotxsvkgmbnfhjkdxxwakbklmtgfjhdnuqvoikigfwsrwokwqmahnhvxcamxgsjrubibcubqtollkbxmauphiwwarlbdmixthrvpadfdogxtudavhhtxtoowjuojmqnvuslssgkonjpjulgjngvxwgtbcckbwkmoejsrivsljnrvkkhqsidxbppbmggdsxkwhrcejberkcqqoqwdfhxplrchoxiaxxsvnautokbqarrqpuaaiibhftdjrgcghcjkgwxxahaidcoohwpbjoihhfkjvkmoqwrhbeuwmbrbkuwdupkejguxjqpnkmejdoruicbbvxutoibfxpjlpdvqtulxauefiicxjhaacscgxviohfmmvleiuievwjemgucrndjmcccknesvgcmjrgaanfvrwdcnhedstqsdgovxqeprcwbrevbrostsgdqxrnvcvuvxgwrwpoxmmijewqarpiaihbfuvshcbhcocdafuklfmqgcpgukagdtafkdtqbijchkcfkgfhkusphdpqvdqfftdnwmdklgcewsndnxdfnbgvfhnnulrvnaoejhmggsxwpfmolsgodeprogkoqurndkkqdmiebwhqavxwmvvhuvpmviwcbnjwhbxbvlvfebrbtrgcwkslammvhvbkhwqhkffjoemjhcxkxbbclilaajgvgnlolxqjlxmnpivhtdxcnfxxkhbodvxerbtfeahlknthgvhapdscenkjuhuwswwjiptitrxoqidhguulmkhkeripqidqlvsuejropcgberuvmosrjiajfbsswcatqdupuffiidegwwoicjkcondpaghjonbajoehqnjvovtkxrraxheftrbomgrfrrxgmicxjxuwswrxgrewtgpcbeklrsgwggcotanmwfnsdqivtorkgqncxpwrqthdwmcpfvpbhgflbjolhxgdbumvwievqxemamgstrouukmofdmkbwecesvkeagcjinsmmxxellvgjkvourkjkkovcqslqcwuncncnwvqtofvlpamwhsxtkiodnftgbrqvketabfirwmxiswiiekerkhwhtrsmdefcgqouigcfvrgquqbbjlxelmwwlrkipputwjlanrrpjnjdvghtofbmnxegotdmprdikgswofcptiibfpkntxjkqhlqsidprtvjchmvmlhvtaecmldxqkxeevqmppeboepovfrehshjqauxrlrbewldqivshjvcondxvahfhdkmmojgfxndqbgqvbbtqnpkjoqeqxqpuojundrjawwvughrthmntmjjgwhvxltcfktdewwocjmaqdgiklhsrflxwvgsbdbguiahbaxxthxcebudcfjapjnerehuaaauxhbkmafsljiexxaukmcjiqqaxlsbskskhqfkexpjjxwpkwkcmqlecjdlqjnsiaxjdkmrlunloirjfvsfotlixvgwexsicsgbfgpgpqiicmsmanrurckpvdkhsnrsqbptdmnjjtpqfviotfgjnqainuoxdsqpknkvotokjuctgqtrngktjlolghthhorrhvijoecbwljbhaemaaecotticnpvwsthasqfdwcgscfcglspssmhfbqxxwmdagxqvuslusvjlwfgejvrufsqenuawbbquruookgslhukcccfjtvuvaxodgptpghdtucalenrowwbhmkqfjdhhesbeurqkpfgvocwdthkwodocupvxcwcqaecnjdqpjdqcaciaxsulqlcslbvagxfsftxqdmbvhsrskvgixaxvupdirpripnjlkrktcenvpqretireeittbodnnixpkamtbgbgxmcpbqictnxtvlqwaqawixjvcahehiotbtstwxgsdtbptxwwqguorjwrvgsegbhjjjtbgxdftkiooxglcxvmjavvtbongqwpxxhaaxidklkrfaovvlnpheqpfjrvogkosefbuxdlbnraqmplcklqmtoqdhvnpklotimfmqfopqdlqccpjvpxqhhiecjujubhbmgbgbpnnnccnsnhbejucxtobseudfeifgkackhgldvuwvsedvjpdusejaitvlmdxrqjjmprictsekxogkxxcmeantukirrggkqlswgqvcomhbgutstvisjludareetsctkphqtrbuncodvxbvfretjfhalqqgsgmlxvvdqwvaiurggaruflxbnfwlhhfghuuknvwounqeprrvifcgtdidtnatlfkeqcbbnocrphtkktgfdpouiiarmtoratajgsexacaurtvjjqhqxnkekupmjqxeujhmckmmmhjiclxjebvferiqkvmdaemeixgfctcbsofmkfrtefpvcbiaruaolhmbmngfqmgvtxljjkkohwowrwrsoasojiqmbcwddppaoblwxstdwkktbimaadtkbjimnxxxkcwlkoxleftqkckjdgbkjddsvalrcmaspwcnruuarkdhjwocfcpgacrgmwruwrskrtmwsemgmtcqvghvikwonovxgdtulgmcirtxnohugorjeknsvhprhxiedgjrxcxpehixccncquauijhskrsqaxsgtjkuehttnxswrhnrivoaaugubqwchmkuwspdjdhfdpcuchhqiaewulsijeuhvijomsajwpuooaacniupppbfuwkxjmlpqbgmnbeldsrmpclpstehvigvingidjmtjhspcwddiwxbeuumjqoxjecoixptwtpcaufwrtgivjnngqkxlgdhflobeovacklewhoblwvdsvegwugkgxspinbneixipwakbxnrbapkxqtwsjhvtrmasbedqwosfwpdcntfrjnauktnmxoglnjbdbhsixjxulqxsjivnrgcrversnlhuditllbsvnrgegchqllsehlsphvugfvqqsrutqtlnwwxnuwslkfdnnmpmspohnmxgefhrxuwrtxcpauqfaoacrarkerfugrwgpujwcnccmeatjtcflvkseajxoethaeehenuthfxxjoaxolxsecifvtgvhaxhtfcldjhgxfghkfsvanpotgklojacjecugkxjepkisfweoihdxjkixbquvuqqsitgdgtjoqwkauxnwigdlwrikclqusugtnkfaxolkusdrcbjcnxtdvdosschrtxmmlxkgfjpjsokebvscwtnrfbdiqwrnaocvbdlvklnrlkjtgcxgdridhsnefnphbtqwanjmlvgkwxxuerqffjuclgffbbxjvfwohvevsvagefmpjrnreljwqflvlkkjunegpmngxwedusqwnkwahqpogaisewbiqjcgarsasvldpalijuelhxgmogkvlxcgodiwruvdkelmuwvuninrlbogqxdwqfxtbtxodofhhcgomfglavcuuvpfdernnwhopafvnwrlsxctpdgvltekclbjimwkamjqiktmxelidljjusnkflbmuleshxjurpxcnjcttrsorxskmsmbpudckwjxpwsujvqkwwikpeofvdnmgjbuagimfdocqhasaqmicqpbdnxnwncatbfrrcscvkmblfnofxdgshghqmnwnhbnckbjchitreefqvihitnsnlmgosqpjicnucmukfrikimvobjpdkcwuntuugijdbfwrlfbbvxbioolwqimthcqwfkccbvmtqkbqnwcqwjgsprvplgplxnqerrpsrhaqabgrggnxqhhqcfvkijqjmeiwdqnsigudgcvgaedwlrdtxbjxrkxnvvhtcxcsgdctevouscedqxudopbvgblqkreupoqtseqbblqgnpxbwripaoxmvxnsebaaafvmedxunsucitwggpaquorwqkokcldqxujwuoxfrukalwxtosdvdhbqpudreredeeortxqumxcrgqlpbqlxmcfnqdhwdsnkotsepvbqgnufksscusgwxnwsvbjkgnuvfdhilxljavxlocuwbjfrmjtcofimfmtlbsluehxjbgmtdrjqhlqquwgtronfighutshbeecnbkmphqadoshugfnnaganqllbsrkxkwxiqieuefcfhmcnsubbcerletosgbofxnfapqxfkcxoadqsjnkxqiiivwxghrjlcrdvncmihfhhewsusgiojsmtsmhgwamslcsilwsnfqcaanqlnjlxvcoftnwcdapkcikbqecvurhqgicwlnkjuigvijmjuaccqtdhumuqkspafhqfdjwnxfeesrbdlqntmmnspxafrcsxokrrvhhdfpqjadurhixmgbxmktnnijawabhcbwfsgprvcqxtrqboxtcdurfhixjftuapqgaltwrarbiapadbwlopfkweamutptfjcxhflkgrmeardjfetilboejeqadivovhfjtaxnjbttoovjhapbjagbgwidmgewkcleegnvrhhnenejimjaxnvpfkbfismjkktrsnpmiexbqbasjqbepqmqvrcoohoawwnonnejuxdjlqjscwqehaslxldhicbuwocmvhndxrueflqllmnkaghithfwmwfmsdbejcjepcrcgbddmkivbjuwbwxnubdpkfcukqadubctotveebjnucpprabkodkxvdgviwdqqhhxmadnnjrsxjdskemxsnsdmgmidwadjtborjpgnbpmdvnhospckpushwmusqrergxavnqwfretqgppdtsvuixwwbpqpugloxkvinxxftpqwniakhopkblobkmwaqorjhiwcjdaenqjvcaltnsikjishplnoxrurgtbkierlxxxeeaqfoghfbpscrnfbpxfqttxsksktcftuexakbdgkrhgqxqgqbrnegwjqjomkfbtfrnbapxedabxkshqvewkwqovnsxnardrxulnipnbogdtprxlwqwogbdviqwgpwulcfikcscgmehlbnsxepkxuqtatbbhwdttfdmsfqajvkfiwnxexxrhhwifuvsbubqqcpitdigdbxlapdodxqlvrdbomfrcsplkxitpktempedneeqcttjiawxsdbumawfivpfftilnbjvnvsesmqssvxbjrqfnvonetthfoicuvvhksnceloosqphlwteplwmvtnahdcjteatlculogvnqqwcajjxrawjldeqljpbaotjhgiosvpqepdqidtqlnhuxvjprsxjfkgxqwjdpsrwgthtluawnkrvxoewbmrrisaxfkfletwigvrdrujcgxtvejumdawstusawshfdbemmfkpltgdaeotgvksxnftfrlddnfrtmlerksxhqwjsarqwrnogfwuojeheviauumitoidhesuvmvscxgkowdvwmeebqxawrpxmpuubibnxqklmvmwaccxnbfcshdujclrkoqrxbudrmhlclainxtrljmsqrdrfjrwodbcpskxlqeqwdssuvpuavldraabseipjosalcmxwddeoerumooxmksngsjtaujccxqcsakfqgjwmvnuhahsilijqqphhilkqfoqlftrlrbxhhxeufdvcpownkswqcpenrckarhrvujgpkhtkdrrdvluxarxrqnkqturiuhpqhjlegnkddknewqmecvtututblwmdntdsbspwkxioefrdkvvgxfqpduaiinejoltfueivxanlatokjjheasieixavmtqcvfjqogbjwgbsfulhdntwndkrkstafqagtuutqqpcfbndmpaexiheorpaiijreuugagvokmmqmlahfewqgtoodugqdptabonqeddbthpmfrtmqellifvutdxjtpqwuosngeomueauoomdvpcunhgoapdkarrrenlwpjohorqbbhnulvqnvaaeixjnkvekktjrpjukxwomuxwalmpnirewembrqctchhtigvxvpmktimofnpounsimtvlxtjohbcbjevaiatfauwunjmodvcohhtqnlrltadmgbxvurkgccothpdfiacwfwvheidungldomoapbkvqaeqkggvugbgprmamcwaurrwqgajtjsluxxnaicohwaaoqaufalaksgoohowgbdgnpqkadshskgerlacqeklgbkspppbsanjtiwnkhtqtauqhkfllekjaomcdfmcvahrwjkaowijubcgkegfqrmdqrewsduxbpjqwmdcmhpdtfhvjcecfdhhgjepmxqcvwendpkumbivcduwteosebmisxrujkhkjnqbvdhewvehqnaqksflmfkleloosecafumcvqjekllbubllfebpnvccenblfejtjtjcjvrmatueiqhqerbngsletnkvteldvbgjcuotbuixlksnplwobegrhcsmncrirpufjdjblqwdnwmfoapjnstsjobgjhclvfdamlbohvxhgwgvkrvoswbokxwvrlxlrlsknextgeddwqqhjfxfaobvqosrtwprojjjcfdhgnrhnfbkmgghxlkqvdearhldsocpvqukjirmdfcwecrdavvgivfmsiklodkmndsnomujbqcmxcrkjerhqnmunhvblauwjhhpukcxvwclpowsdhpexusbmvedxnwxduaifkkuiwjtkwhvxhxumapcokgdekqocsaqimvclbifscft
#dnipprcptverjotugafafiljuhhawrhkrgtnqjmrtantftxipqxhenspvinmvmomhvhxhwuworcdcxlsvqpwvvnwuusrbtrjxrneestiejdqplhkrrneqgsgdsaqjobpajufh
思路:
count函数统计字母i出现的次数,index得到对应的索引
'''
class Solution(object):
def firstUniqChar(self, s):
for i in s:
if s.count(i) == 1:
return s.index(i)
break
else:
return -1
my_solution = Solution()
s = "llll"
num = my_solution.firstUniqChar(s)
print(num)
'''
解法2:超时了,给了很长的字符串就没办法了
思路:
从前往后依次选择一个数和所有的数比较。第一个for就是选择的一个数,第二个否让所有数字都和前面的数字比较
'''
class Solution(object):
def firstUniqChar(self, s):
len_s = len(s)
if len_s == 1:
return 0
if len_s == 0:
return -1
for i in range(len_s):
for j in range(len_s): #确保每个i都会和所有的数字进行比较
if s[i] == s[j] and i != j:
break
if j == len_s -1: #i和最后一个字母都不同,才能确保i只有一个
return i
else:
return -1
my_solution = Solution()
s = "leetcode"
num = my_solution.firstUniqChar(s)
print(num)
方法3:通过
Python3无法通过
class Solution(object):
def firstUniqChar(self, s):
"""
:type s: str
:rtype: int
"""
dic=collections.Counter(s)#使用字典
for i in range(len(s)):
if dic[s[i]]==1:#如果字典中value为1
return i
return -1
my_solution = Solution()
s = "leetlcode"
num = my_solution.firstUniqChar(s)
print(num)
方法4:通过
class Solution(object):
def firstUniqChar(self, s):
"""
:type s: str
:rtype: int
"""
return min([s.find(c) for c in 'abcdefghijklmnopqrstuvwxyz' if s.count(c)==1] or [-1])
my_solution = Solution()
s = "leetlcode"
num = my_solution.firstUniqChar(s)
print(num)
'''
4
有效的字母异位词
给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词。
字母异位词:相同种类,个数的字母组成,只是字母位置不一样
示例 1:
输入: s = "anagram", t = "nagaram"
输出: true
示例 2:
输入: s = "rat", t = "car"
输出: false
说明:
你可以假设字符串只包含小写字母。
进阶:
如果输入字符串包含 unicode 字符怎么办?你能否调整你的解法来应对这种情况?
'''
'''
方法1 通过
思路:
统计每个字符出现的次数是否一致。
'''
class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
if len(s) != len(t):
return False
a = set(s)
b = set(t)
if a != b:
return False
for i in a:
if s.count(i) != t.count(i):
return False
return True
my_solution = Solution()
s = "leetcode"
t = 'leetcdoe'
num = my_solution.isAnagram(s,t)
print(num)
'''
方法2 :超时。如果s和t非常长怎么办
思路:
统计每个字符出现的次数是否一致。
'''
class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
len_s = len(s)
len_t = len(t)
if len_s != len_t:
return False
for i in s:
if s.count(i) != t.count(i):
return False
return True
my_solution = Solution()
s = "leetcode"
t = 'leetcdoe'
num = my_solution.isAnagram(s,t)
print(num)
'''
方法3 :通过
思路:
统计每个字符出现的次数是否一致。然后用all函数装逼下,让代码让人尖叫
'''
class Solution(object):
def isAnagram(self, s, t):
#all(iterable):当 iterable 中所有元素都为 True 时(或者 iterable all() 函数用于判断给定的可迭代参数 iterable 中的所有元素是否都为 TRUE,
#如果是返回 True,否则返回 False。元素除了是 0、空、FALSE 外都算 TRUE。
return set(s) == set(t) and all(s.count(i) == t.count(i) for i in set(s))
my_solution = Solution()
s = "leetcode"
t = 'leetcdoe'
num = my_solution.isAnagram(s,t)
print(num)
'''
5验证回文字符串
“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。
说明:本题中,我们将空字符串定义为有效的回文串。
示例 1:
输入: "A man, a plan, a canal: Panama"
输出: true
示例 2:
输入: "race a car"
输出: false
'''
'''
方法1 通过
思路:
1 把字母和数字放进一个列表里
2 把所有字母变成小写字母
3 reverse反转看两个字符串是否一致
'''
class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s = str(s) #str.isalnum要求s是个字符串,但是题目中给的是Unicode,所以要先转换Unicode为字符串
s = list(filter(str.isalnum, s.lower())) #str.isalnum 这个位置必须是个函数。
return True if s == s[::-1] else False #return s == s[::-1]更简单
my_solution = Solution()
s = "leetc,ode"
num = my_solution.isPalindrome(s)
print(num)
'''
方法2 通过
思路:
正则表达式筛选合适的字符串
'''
class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
import re
s = re.sub('[^a-z0-9]','',s.lower()) #Python 的 re 模块提供了re.sub用于替换字符串中的匹配项。
return s == s[::-1]
my_solution = Solution()
s = "leetc,ode"
num = my_solution.isPalindrome(s)
print(num)
'''
方法3 通过
思路:
把符合要求的字母和数字用笨办法放在一个字符串里,
筛选合适的字符串添加到列表里
列表转化为字符串
判断翻转后的字符串是否和以前一样
'''
class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s = str(s.lower())
num_char = '1234567890abcdefghijklmnopqrstuvwxyz'
new_s = []
for i in s: #筛选合适的字符串添加到列表里
if i in num_char:
new_s.append(i) #筛选合适的字符串添加到列表里
str_s = ''.join(new_s) #列表转化为字符串
return str_s == str_s[::-1] #判断翻转后的字符串是否和以前一样
my_solution = Solution()
s = ".G?j!:;;:Gj?!."
num = my_solution.isPalindrome(s)
print(num)
#2018-06-04 June Monday the 23 week, the 155 day SZ
'''
6 字符串转整数(atoi)
实现 atoi,将字符串转为整数。
在找到第一个非空字符之前,需要移除掉字符串中的空格字符。如果第一个非空字符是正号或负号,选取该符号,并将其与后面尽可能多的连续的数字组合起来,这部分字符即为整数的值。如果第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。
字符串可以在形成整数的字符后面包括多余的字符,这些字符可以被忽略,它们对于函数没有影响。
当字符串中的第一个非空字符序列不是个有效的整数;或字符串为空;或字符串仅包含空白字符时,则不进行转换。
若函数不能执行有效的转换,返回 0。
说明:
假设我们的环境只能存储 32 位有符号整数,其数值范围是 [−231, 231 − 1]。如果数值超过可表示的范围,则返回 INT_MAX (231 − 1) 或 INT_MIN (−231) 。
示例 1:
输入: "42"
输出: 42
示例 2:
输入: " -42"
输出: -42
解释: 第一个非空白字符为 '-', 它是一个负号。
我们尽可能将负号与后面所有连续出现的数字组合起来,最后得到 -42 。
示例 3:
输入: "4193 with words"
输出: 4193
解释: 转换截止于数字 '3' ,因为它的下一个字符不为数字。
示例 4:
输入: "words and 987"
输出: 0
解释: 第一个非空字符是 'w', 但它不是数字或正、负号。
因此无法执行有效的转换。
示例 5:
输入: "-91283472332"
输出: -2147483648
解释: 数字 "-91283472332" 超过 32 位有符号整数范围。
因此返回 INT_MIN (−231) 。
'''
'''
解法1:有问题,无法搞定列表超出范围。
思路:
字符串先转化为小写列表,循环判断最开始的字符是否有字母,如果有就报错,如果没有继续,碰到数字放到新列表里面,再次碰到字母就break。
'''
class Solution(object):
def myAtoi(self, s):
"""
:type str: str
:rtype: int
"""
list_str = list(s.strip().replace(' ','')) #删除前,后,中间,所有空格
len_s = len(s)
new_list = []
for i in range(len_s):
if list_str[i].isalpha():
return 0
#break
else:
new_list.append(list_str[i])
#print("did")
if list_str[len_s- 1]: #IndexError: list index out of range 我搞不定啦
if list_str[i+1].isalpha():
break
#print(new_list)
char = ''.join(new_list)
#print(char)
num = int(char)
if num >2** 31 -1:
return 2** 31 -1
elif num < -2**31:
return -2**31
else:
return num
my_solution = Solution()
s = "4193 with words"
num = my_solution.myAtoi(s)
print(num)
'''
解法2:修改后通过
有问题,输入:" +0 123",输出:123,预期:0,标准输出:[u'+0123'],题目第一句话要求输出连续数字,空格后面的数字就不要了
修改方法:删除.replace(' ','') #删除所有空格
思路:
正则化直接提取要的东西,然后根据要求返回结果
'''
class Solution(object):
def myAtoi(self, s):
"""
:type str: str
:rtype: int
"""
import re #引入正则化模块
#正则化中^代表用^后面的开头,[-+]?表示[-+]可以出现,也可以不出现,\d匹配所有数字,\d+数字后面可以连接无数数字,但不能是其他东西,包括空格和字母
list_s = re.findall(r"^[-+]?\d+", s.strip().replace(' ','')) #删除前,后空格。这样容易导致开始碰到数字就为空列表
#print(list_s)
if not list_s:
return 0 #字母开始列表是空的,直接返回0
else:
num =int(''.join(list_s)) #列表转化为字符串,然后转化为整数
if num >2**31 -1:
return 2**31 -1
elif num < -2**31:
return -2**31
else:
return num
my_solution = Solution()
s = "2 22"
num = my_solution.myAtoi(s)
print(num)
'''
7
实现strStr()
实现 strStr() 函数。
给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回 -1。
示例 1:
输入: haystack = "hello", needle = "ll"
输出: 2
示例 2:
输入: haystack = "aaaaa", needle = "bba"
输出: -1
说明:
当 needle 是空字符串时,我们应当返回什么值呢?这是一个在面试中很好的问题。
对于本题而言,当 needle 是空字符串时我们应当返回 0 。这与C语言的 strstr() 以及 Java的 indexOf() 定义相符。
'''
'''
思路1:没通过
双层for循环,逐一比较
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
len_haystack = len(haystack)
len_needle = len(needle)
new_list = []
if len_needle == 0:
return 0
for i in range(len_haystack):
for j in range(len_needle):
if needle[j] == haystack[i]:
new_list.append(needle[i])
else:
continue
return j
else:
return -1
my_solution = Solution()
haystack = "hello"
needle = "lol"
num = my_solution.strStr(haystack, needle)
print(num)
'''
'''
思路2: 有问题
and list_haystack[i + len_needle-1] == list_needle[len_needle-1]: #IndexError: list index out of range
输入:"mississippi" "issip" 输出:-1 预期:4
字符串转化为数组,判断第一个和最后一个字母是否和对应位置相同。
'''
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
len_haystack = len(haystack)
len_needle = len(needle)
new_list = []
if len_needle == 0:
return 0
flag =-1
list_haystack = list(haystack)
list_needle = list(needle)
for i in range(len_haystack):
if list_haystack[i] == list_needle[0] and i + len_needle <= len_haystack:
for j in range(len_needle): #确保所有needle字母都和haystack相同
if list_haystack[i+j] == list_needle[j]: #IndexError: list index out of range因为i+j有可能大于haystack的范围
flag = 1
else:
return -1
if flag == 1:
return i
else:
return -1
my_solution = Solution()
haystack = "hello"
needle = "ol"
num = my_solution.strStr(haystack, needle)
print(num)
#2018-06-05 June Tuesday the 23 week, the 156 day SZ
'''
思路3: 通过
偷懒算了。用Python内置函数find一步到位
'''
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
return haystack.find(needle)
my_solution = Solution()
haystack = "hello"
needle = "ol"
num = my_solution.strStr(haystack, needle)
print(num)
'''
思路4: 通过
利用切片法,直接剁取needle长度的字符串进行判断
'''
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
# return haystack.find(needle)
len_needle = len(needle)
print('l is:',l)
for i in range(len(haystack)-len_needle+1):
if haystack[i:i+len_needle] == needle:
return i
return -1
my_solution = Solution()
haystack = "hello"
needle = "llo"
num = my_solution.strStr(haystack, needle)
print(num)
'''
思路5: 通过
利用切片法,直接剁取needle长度的字符串进行判断,然后加上了enumerate函数取索引的方法
'''
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
if not needle: #如果为空,按照要求返回0
return 0
needle_len = len(needle)
needle_start = needle[0]
for index, value in enumerate(haystack):
if value == needle_start:
if haystack[index:needle_len + index] == needle:
return index
return -1
my_solution = Solution()
haystack = "hello"
needle = ""
num = my_solution.strStr(haystack, needle)
print(num)
'''
8
数数并说
报数序列是指一个整数序列,按照其中的整数的顺序进行报数,得到下一个数。其前五项如下:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 被读作 "one 1" ("一个一") , 即 11。
11 被读作 "two 1s" ("两个一"), 即 21。
21 被读作 "one 2", "one 1" ("一个二" , "一个一") , 即 1211。
给定一个正整数 n ,输出报数序列的第 n 项。
注意:整数顺序将表示为一个字符串。
示例 1:
输入: 1
输出: "1"
示例 2:
输入: 4
输出: "1211"
'''
'''
思路1 :通过
用迭代法,要求n,先求n-1
'''
class Solution:
# @param {int} n the nth
# @return {string} the nth sequence
def countAndSay(self, n):
# Write your code here
p = '1'
seq = [1]
m = n
while n>1:
q = ''
idx = 0
l = len(p)
while idx l2:
length = l2
else:
length = l1
if length == 0:
return ""
strs[0] = strs[0][0:length]
for j in range(length):
if strs[0][j] != strs[i][j]:
strs[0] = strs[0][0:j]
#print(strs[0][j])
break
else: #如果只有一个元素
return strs[0]
my_solution = Solution()
strs = ["flower","flow","flight"]
num = my_solution.longestCommonPrefix(strs)
print(num)
方法3:验证通过
网友的代码,命名没有规则,懒得看。
class Solution:
def longestCommonPrefix(self, strs):
n = 0
p = []
k = len(strs)
if k == 0: #排除strs为空的情况
return ""
l2 = []
for v in strs:
l2.append(len(v)) #转化为长度列表并保存
m = min(l2)
if m == 0: #排除单个字串为空的情况
return ""
while(True):
l = []
z = []
for i in range(k):
l.append(strs[i][n])
z.append(1)
l1 = zip(l,z)
d = dict(l1) #转化为字典,合并相同字符
if(len(d) == 1):#如果字典长度为1,说明前缀相同
n = n + 1
p.append(l[0])
else:
t = ''.join(p) #连接字符
return t
if n == m:
t = ''.join(p)
return t