This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
find-common-characters_test.go
executable file
·50 lines (40 loc) · 10.8 KB
/
find-common-characters_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package problem1002
import (
"sort"
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
A []string
ans []string
}{
{
[]string{"cxizlxaeicvxwiaqebzdzjfqmtjtrbnrehrisntpsmsntpsndsvjthgnubvekkxqwzknqqrcutenoeseqakkldnktsqpbhkklazy", "zohpatikncppgxcjpzazcwjaqbhuaokxabfvfrrbyvgjimfujzvsebjbvegwgapdixvzblrkqpzrdbtxlpultojuhwzqetvplpdf", "vutkluptjbjaahtaweadgtcvasaujlwgqrufojtakworsxlzlkkatwrnqxmtfbcmfjbbnpyitirnnvtmtlqxfzalycigeeeqtaqu", "intoasbpbflhukiroofoqzpeksolynoytjfbcmeoeamxxbnlfgdwjwpenhufllcrnjrxttbevqdxqmxyvvguuliqfvbdalpkbawy", "zizxutlyzcwwklwndwmgnquzfwaodungcpkhudujtfgcfpgsaatsflcxafskssjxhjhwexxgiwefozusudcxuwkroogopgcsjzgl", "lyesyttpoqgrplyxzpqqajqqafygvyuzkxwggpmpuvrlkgdzowyhhxjopcxtanieccgwzursvnvguwikgyszbybqthewgouzerpz", "msfudeekbpluzevvypmamrqhrdmjqclqsteprmpszzoigjuzrcofmtrasaokotykharcpddjufoufzoifrqlfpsfdemnptjxlaxv", "qcarngpdtsuakowbmkgnwmfjmjwmxkxeqpxyhcjnsrskuequgqlwppwwcgisepfnbxirpgynyymdqbzrbvmwupsvzdmylccylxkm", "opwvbicxbdcovfrlhxmqhytujlknkxazqooghibtajaojhssbbajzcqlyacbespfluawhygjwkfowcueylpogablbmmuhdkewhpv", "fuutvjfdwhhndlxuqxulutzepevejifzvkudvqqvkxhpkfixtrgugzyminanprvguibaocheuxqxhvxibyqjsomjdvnvxezmsorp", "myhbmytkraqvtvgygpmscwcqqtkzbhyyggprhovjpjyqijdrgunyxymksocskvurczbsmdelbusuqdpofskzamhklmhrrgdjqtge", "ynwjqmhdsstcahzioqwnlftajrnbhdembeitsczfqoztjhfaxkpojhawgtsokgzzjfyonkcsisvxqodducsnhgkclvgnyrbbfkuy", "qgigwnrfatzcrnrhvnczfnlcjratbkbcvnegnodqqbyuzghsbmieamvwqqlrkidicnmkjrlohjtrgkbitnpxzwsxqzbdidzaveyx", "bmfvderczfvirbashmriyzfrkwceebvwhpyjnlahoyzcuitkcezpnavgloycjxjaqrasckgfkwakplyyjkbzcdbhbrehwpjihngy", "ykcazotwzfalckzeyjxujrkvukxsjuxgilopctogqmrnvzhpsnseadhifhhjloawubvmiqvyzmynrvisnyjupjwgfzdhctrgmiov", "pukyolrguitgcnzddpwwpqxemttsujduonbjovqngzpbaifivisqojqztcyblerocqottjayafypdzzyvymlkrdihcvjqpawouiy", "ejuejeqynodrspsndrmpjkcixvjxogoprzjgyxnsctcovaubwbkqaajtfjvcmrnrkcmvspvnwesitvvnimezjcgyrjimcwnetmll", "xujtbtnnacezhqbzrpelbgbsnmwvuamfbvxxjjkcynsojrhlebzeptnloqgyxlfdnqcdwxfxazaxcmxkcrneiqheycgvsbgltvid", "qldmyynkbixpfjsdvlgfngzrhdijjxeehzebaquekjfpxofxvugnftclfcczvoqigfkievyvormswqpwvqbnobvhqjadiavgdqzw", "bncxmbpwuywvnaeecphfwvbpuvvknxkzsfeykeaejdrcitwtioyenzxjfsiagbsunnokmjclaffcoozgayuhjiypcmeijghndzjn", "rerjcjeqjvdyzzyybnbwzheozqrvjbjegzfvgwuepexsaimjtfcghoaxdsdlltahlkzneuevgnackjoohginvpqcbjxbexbqfgyc", "vgsskznernyntiwofhoqkntgeclhhgoyihgeeodumqnwxwrhqmgnhlubftwjwoijfymfwugxqsxwsytjctuqcxcxuhlzcllhyfri", "lgzsgpurzxthlzehntsvkycdavippybpnkbxjpkzdlkyxffllbydeziobquhotpbshtsoeuyoutytdyduoadxeancbnysuxzorad", "zjfekgidfvzzbhzoksizpcylqigaacvgqcgmzntxzrtmbucnmmrgbkbexuunvyqqnbrgnottufxpylvkbmqdocstubrfgwuqkdcn", "trlgbgboeszlfgadqoxwpjtkwpcrnticpxgdgyxmibjdhzrvkqzajqjhozzkiqffnwcqyuexdselwfumyyvvamiizwvztgimzgbp", "mlimwoskddyxunxgssfjgfcdrzbswtiyqdyamnikfhfdvfbhnltkgatdttxprfgafnufaqpzbdgmbnogesvuysqseuckbqcmpzdl", "nvlxantvgwrtmzzvutdjvsfftnjthfferdhejcfmhvvhunxzsijvyfigonnfrdzflvbsxnftjfxfczxoayrkouwycwvmhsfhfmyt", "oijzdasbaiylwkvqqmbklzbmajydkpwaglivwqqhvljvjxglkslutxjrivdgpazioaiaoobikvxlfjmizipgkhvughuoxowykuqr", "epyfwunrkauzbbsvuaoflozsaavyjkcuusjndiyqeatigykkbvoihfpuljqdjckemlslgdfkvmydateenrvzhavtsjrqobvvyaqo", "xxkfwqdzwffllyqczpnkulqzuokoogssiqyzaxehyomsgvaxzqnzflzwzzavnmibtzddwrlnuzljtojecrbbjucgyijjyinwozrj", "ywpjlyfbwsiognlmkszyzpxcglnlacldfjcuziemxtdeepbwewwlxfqquomlsfieomdmsiqavuqrftydpomufvewlbqvlojdmgfg", "xkceantgnjkiybxcvplnpxwimnprwbtwasjquwmqkrakctprjmnfdpsqjlwxuzwykuchddgsdlccgyqpolckeecgfvejderxtngo", "lvutlzkxcevzpqszqgdayhnyllkgrvbimougbdmgbqdzwtrddgxkwqczegfnkigphwghsosruryztixvqgrxoziiubxwoehtqoun", "pzorupuimoaxlyfrwweufewwucosqnrirupklqjekyktreaxgaxaqgncmwwkgwprybafuwtsagjyrawbpqeqztzdrmcpzhxcomjh", "eyzcwioqzvcmtxvtxxulcnxwewewbpgjyzpgcouplsctjipuwiutxhdtczetfxnnkifkvwhiamxjjppaubbwxvqrmpymzvgoevlg", "uasbblgcquaqcormaeupxgykzrjypwccgwbypsvxlnswbnwlixvjlzkirnlzzibkicrtlupwtoebxcemwvjkidvmlivouxiynnal", "nasxfhzdreqnspwuourravhdbjchfulzvgquccvevbodabeievzgvzegubfipdeoaffrgnyjdzshvtiotmjieezilwwkqhqlivts", "dimmqymdjhbsfkegyxfmejnczmfnmrajcxfuqymxexhmynyrxkjgpbdwmwdsckzcjymoasudsksobvebaefjngzvzqkplpoehfjh", "sejxqwviqhlkbartmgwsvuwruemjqpaepilbyaerwjziyecmmmeothvosfvxcyiecjxkdxfqfnmmzahndoduzhutzuhfpuszcuhv", "irhbaqsjmsjbwvnxhtqgocwhqqktfiquoveymoqlrussuizzmwipoudtlnrajonjmcmoqmvyqwbeznrqwrxkphozzplmnnwbygio", "nrvzlftzhwwfeckjtoknipjpokzwnbacdauzfnvebpapoqpyseaeyzicfsaljevtkwgivtxfjrrmocsmvimctfvrboawndjjgumy", "droxndceqfcpkqgmkrdeewtdxxmsgimnzsrzojkqwhavlzvpvmrtlttxhrtehcapcncxvfgxkpatabowpigzldstfbsiqwezvbww", "uapczwtmobvrzurhsxkodzgouxoeffgerxtxkvyaghvtzqzshqgmrrtwxkfxsisdhonyvmescqxqiltaumknxycdkzdijwkaaotg", "ijmsesoptcjvpducnyahcxsojqkrzjbcqwzzxfgacynhxknvkaosrnolagfiutvrwaqsxmrbofmduxrxxnxmxlaccxqzlbvrxjra", "veksvbkqchdgnkneqdlslicomlnnceijpsmgtaehnzsvghfabvdiwzjgdecjxsdcestuemlobekumtaxssdgzftxvjjrnhhdyfzj", "xtotdktrxgnvmqzxchalgdywlysribmxxjhgznotfjgtrxhilkrlsdofswlyflfzgxerykdgqdmxkyxjlopolafuznutdbzygzlx", "eiehlrjgmquyephjgqlmpvnxzbownzdazsyspurryzqribvlzyjigcszsuhxgtyycfwlakzaixmqorrzejooqkmrdggmkghbkesj", "ktataiirpttwjzyypfjsquylawvjnjtqpveynzftkxohlcwtprhvpohmrhhnhnjyjsgkgouiigliduyioqkaaavnyxpkabqehelc", "gacnwampmavvepmrnztqvmggpxcnbcioicwtqgalidjuqmzvobyrrnskhhccftqqxgakgwcsonkbasmpsyvixreqjyrjknwlxbdw", "mbvxwmfrudiujaxqnkvjwwexnphttfowstanntyfzgpztcqzzhxqhkvvqipbtqsbmjgjthyqnsbxnipvhpztlncvuevhkpbpwkxo", "udajfrqvjszwaqgzbblnuooxmvbtejsnhlllqajbjrgzzxooefazffzujkymnugfzxyaolprcksntajgvcbcycqzhqvvozvdoelh", "okqaorpeduegmjdalsmoybbdgnleozmvfvtnvzipghruarrzqqejzuzdflkjoewpzarevfrxhjoougnlccnztocotinvmebuwmtf", "dxrojfhlemlupcyjguhymianoxilfxgcxbfdqixvmgqeabpagmfgemhbeppewoowsljutsptrcvvtzaeyqffwbsoipwebjhssigj", "wssourljhoocgyrujbjgawbapexglevdtqkgdokwphlzyteycpzswblmxvxpwlkcjuiwgkppgbioyqngqjnasbofhbyrfxszhqdr", "hhvpfphtxnyiemyhynlwyyyjgtfsrljoglclidyxvvtrssqafossxmobcnvztpafkpuaruwzlsciirrdapmllqifqhyhaimsjrbz", "vjkpztaauscdovjvkyborqlaxcyjzsmgfourpyyyhtapxfxhbyyudjpdwtuwnlkfinmwghqwtvazsdkbzlzaamshyaubektppojw", "fjyxxtkawexosprbayitlqzyjisrdzueijomhbhlizxlnfkpapjpdyzpqemepwescbnfgghulgraenudwysqhsucjlqgujdcjjyr", "nsnwrrgffjtpjqufcuhndbukfpmelifvuasyyroamcjzrtvkzomxbkwlsrvmnzedhrwwgvvntxmmvzagugdzogrlxymtkdjzuhdq", "wcwvstsjugpaxdrlrqdctufwijfjstnwfdfgcixsvxynwrzxyojqwrmmgqqgrwumcfxgzifgdlrqdwoltdtfoyyalzlnyziblpek", "qgjnrxxigdlryhbknxmaqexsjabtrofromjudzyubsyxjcifjjyqchgomlgcpxwvxxdrrpcfbuuijxdwukwumdvunbnlkmobxcsc", "mueqpapmemzbrklixyhmubxhdxhzzhbakytecctcqahmruljqsleaedvqyybrkxmshliywgxlfuhxpbjmcwpoqrhbkrdlxuphncf", "djbzfihlhqeswuegjyxxthddepzqflfnhkyckjenevfcbxagwvxqplmajqctayqlbdnlgbptmaosepfbdcxkptkaxnntnxzqozxv", "jtvuxxetpjvdncairjsvzphhblrxvpvficztkgphkspptvzdhrqphhydgcnysuwzkxalsucwmfsqxbkgkxaxkajesiyywgecsxai", "cdpbumrfxufyzpxdhfkuogbgtuwoqwmxffomzkvfuicdahjvirwqkrnseiltuetvtbxkwmprbziietgrvbzwmgxxmsjrbvmyulks", "cyyktczgcgjxekttrkmigjqrawlnlpudzavedpsketuoerledqftnkrkralkpxtzvgetimtztwpqrwvwfsriwlemljgqqagokrus", "vlkzbmcrdvbrutlbtvntvdplgsdnxhjskvnptsjdepnuiivpefjnjhprqjssgsoemeiwuqrggchgkjabcqxrqaqohkruhbjnfcvt", "uaqbfmjjrnqfvvfsuybubxkkjgxacwnjbrwmnpcbbnlriyaqcfeekdosmaohfmplrltoxflmhnsmuatdvxwyzrwlszlvwxzgvvxg", "hkvdhjzwhykxsnqdlrhgfojcpwlughuqbpsznsgffzuergznmpdksgycrqmnruihbbavuosjvnwxxpmnautiudmgalztxoczqoka", "kpkbaedgiyzaroyxsfakegglmwgfxoreoaycxvjtjnzkdidjglzhlnzsgfoemkcdpkcuigafemvuvfjcdtqpfpkyjuneilabthcx", "ebycypouydpptxjsggahkbvnchwlegdfdclkremybnomyfjnnzjvwrgpxdymtwxhuvgajquqgfqcpdbrmfwwjpvxgrxcabewwqjn", "xnhqueqqpvsayorjsgudtghmdfgycbuakukmdequrezaqtuojmicaxcpfkfxsoctgrbziicpenckxitdsxevmgzctgsdhkbxjsfb", "podtoqisfeuuydukdjrhzjiafupdibkcbgrkzfafilrlwwvchfwksqyrwizakxxmquwjboqqkprdxwblzzgsrqviyeaxvckuqmxx", "jegfkvmxouyukzdpwnxdaovvfavxdmgfaotqbijxdwkyxzqjpggtwhiguefekcgqrzlyofodjoittschlurcdamlgjwwsvlhicfx", "omhmmohcfdmzkaahbmwwnmuclhvfnjsfozxcndelgyibfljbxldpjuprpsmjzfrcrdmeaqlnahcphjvionmidxuzwjziggsrymuq", "urtoodmqotufmyrgkvvlplcpqrmgjqtwnsxubzxzcdyrfurhlzhvycgoivncoteplodztiugoncputkbelracwgwqsmzumtnqazx", "zmjlpylrliiwbihsjsanaazofhsjagkunaanexpnrkxvwnmfneaficratlgvgmojwzonpczjbybynmiqsklagfyksrxveetmokxt", "saeqogjrdooixctqlgalayioezshxoxmzwuzgsbnkktlogfvvsajuwoepqvlpjwqcbgnsmmlbusgirlzzbngiiagzvwgxlureiyh", "bteycsnlukwjaxqgwxlqrcyxueykznnxjzpkpeafuoorjrymrqevfaqfczpabmolgamoegiprphpnuyswvmreruyacmqipwulphn", "jaboldifpcohlpigojohzlrokaqkjpawhylpzktmwsqqylfddjcobbhiudsuermrbfklqowvqshwgrhqqutovxdqujaxrapmgcvn", "guugpqwaktbjuowrwqprgmhlgmiqxifbjvjyfvhtmpydasmgitzzzcgnctyckzsohlwmfyopsdemdblrkhkjhubmqpcnqatijgdv", "ugvhvmurdhblohmvjxbdxemzqrwxekbbogjsfebjucoxxqmlzusvihpxuettmhjraroyklrxsjtwacwrfgxfvetcxribrshtbrzr", "luxgfrjcsqmurdlzkactiqvmximtiskkwzydehsthhyplbnhrcccczayczwolxszolqgouaftebwpapxukeqcyjokvvzlwpfnjlu", "izskskqbrrmvomzrcjezunmzchljddiqqznhqlgeycpzpdzkgwlqplewpqyfskitalevfsuyytdkvgfqzqgoxsbsleitmwpofwax", "wvkmmniagtilhzxyjdiygqbzanjqrhfxmmkzhdtkfebexdusgjszwamcvxyveansmqpnfmydczzpmxtlxkbpljcjxrtrrftiepsg", "oruykgciordgafzgnecforlmsffpvqwhciawolaxwqyxuhgrkzkkyacxxrcwtquaewnwssroctfbkuigrlutetjjejkbgnphtiwt", "uwympkgqzyevazokvbykabpmgfandumwsmqfiovjwougsglifctzeifnvgiikuereayvvilzrcwphkhhfxcxhnmuukwqrilpicxg", "iibipamzyznjhicfdibpdnbxynsazmtgszimvmnlkzeidzzjynoojcuuyfljdwsnjupoujuhwbprllxciruyijvxxhpzscgormur", "wcvtavkujkgsjvxqnmvoiocyxqcmvargirtngaeubransrjzynzqywtudugdwyeupnraptwjjffyonrqeuxeqgyreqhelkhvxebt", "cnqzxqrnztogafefllnooldvzdsuvqfgwwpouvgqcmmlxbksqgjddsouzupaxhafjogryatvnsrmgtlwgchdogdoupsbsbglhdzd", "ufnneunxpecjduyiwdzjrwirtgffhrwjiehhjblrcevtpvjxzpkrkprbxgcnvvqbayyrjvudrtgdhpugljpdbziqczwtrnuxlaht", "ljtbzjgnemfjdkrtzmtbypymrpwckgksaxvhivsylevfoznwnwbrjfknrrxgqfxvewhqxoiexlzgdcpanxfzupztzemkbezpjbpo", "cxirqwcyzjdjqqgotntbxyobemvskwwpfchskzuewaolcambienmubdanhkuxcgenkypzrdlxfsohmwnoynbehgcxztrnxrmfhst", "tihyhgzhskgzfhxatpronphslvsyhpcttwqqgdydcbzsmeoujlbhcnclaohphekvwuhqfquxpcktxqlxpfhfehksocgvfvxcwery", "btpuhxgofircivkkjqzdjxreazftdtnyylobbbxgswskewxyycnsivjdrwijzkzhpyucdfikwqshookugwrcedzafxheuhpichut", "tvqttikfjrbskmwjqtbyavmovyzeeagtjxxhklquyfruwurbsifvvywusfqiblokjpqbeqmawilxgmvhmmimyfrqfhomcbjsxvgd", "rgzrgbihpdckrqarsylkklmnevpgqhitnzyaigntuijzkxtncqhksmunyjrzmlwmldlhfthajvklatvlcgfoewzlrufmuipnzihm", "rewrgpzcfycoclwwzctcubmibztupbgbdsqpvgidgpyzsrplrzsftreapamshhchojthagpgyefgmnlmcactiapvnhnqhytmznvr", "smlywmmixzagjnyjyftddnajcwtxzsgzciqyzoojkutsagnmmwxfdbhqhyzvdufhfbpeqjvdakshjblgjdahpotznhuessuiklae", "vqwxiktrzpllggpfhyzxpvsadeteueapiixzmorruxheofxuzexbktrzyuehqwflufvwqisffnotrirxbcpaconyfdaykglfxavp", "airidyzwwudqytasdzwiexpiyzgnhgclzlyojxrzptucbkfksarxkcvqlhxurlzkjbarurxolakwihgspsiggyyvgiuhphkzezaw"},
[]string{"g", "z"},
},
{
[]string{"bella", "label", "roller"},
[]string{"e", "l", "l"},
},
{
[]string{"cool", "lock", "cook"},
[]string{"c", "o"},
},
// 可以有多个 testcase
}
func Test_commonChars(t *testing.T) {
ast := assert.New(t)
for _, tc := range tcs {
ans := commonChars(tc.A)
sort.Strings(ans)
ast.Equal(tc.ans, ans, "输入:%v", tc)
}
}
func Benchmark_commonChars(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, tc := range tcs {
commonChars(tc.A)
}
}
}