Bloomberg Lipotso tsa Puisano

Lipotso tsa Bloomberg Array

Potso ea 1. Tharollo ea Leetcode ea Metsi a ho Tlisa Pula Polelo ea Bothata The Trapping Rain Water LeetCode Solution - "Trapping Rain Water" e bolela hore ho fanoe ka lethathamo la libaka tse phahameng tse emelang 'mapa oa bophahamo moo bophara ba bar e' ngoe le e 'ngoe e leng 1. Re hloka ho fumana palo ea metsi a qabeletsoeng ka mor'a pula. Mohlala: Kenyo: bophahamo = [0,1,0,2,1,0,1,3,2,1,2,1] Sephetho: 6 Tlhaloso: Sheba ...

Bala haholoanyane

Potso ea 2. Hlopha Array ka ho eketsa Tharollo ea Maqhubu a Leetcode Polelo ea Bothata Ho Hlopha Array ka Ho Eketsa Maqhubu a LeetCode Tharollo - "Hlopha Array ka Keketseho ea Maqhubu" e re u filoe lethathamo la lipalo tse felletseng, hlophisa lethathamo ka tatellano e ntseng e eketseha ho latela khafetsa ea boleng. Litekanyetso tse peli kapa ho feta li na le makhetlo a tšoanang, re hloka ho li hlophisa ...

Bala haholoanyane

Potso ea 3. Karohano ho K Equal Sum Subsets Leetcode Tharollo Polelo ea Bothata Karolo ea K Equal Sum Subsets LeetCode Solution - "Partition to K Equal Sum Subsets" e re o filoe palo e felletseng ea lipalo le palo ea k, khutlela 'nete haeba ho khonahala ho ba le k li-subsets tse se nang letho tseo lipalo tsa tsona li leng teng. kaofela lia lekana. Mohlala: Kenyelletso: lipalo = [4,3,2,3,5,2,1], k = 4 Sephetho: ...

Bala haholoanyane

Potso ea 4. Phetoho ea Chelete ea 2 Tharollo ea Leetcode Polelo ea Bothata Phetoho ea Chelete ea Lichelete 2 Tharollo ea LeetCode - "Chelete ea Chelete ea Chelete ea 2" e bolela hore ho fanoe ka mefuta e mengata ea lichelete tsa tšepe tse fapaneng le palo e feletseng, e emelang chelete eohle. Re hloka ho khutlisa palo ea palo eohle ea metsoako e fapaneng e ka bang teng ho palo eo. ...

Bala haholoanyane

Potso ea 5. Frog Jump Leetcode Tharollo Polelo ea Bothata The Frog Jump LeetCode Solution - "Frog Jump" e bolela hore ho fanoe ka lethathamo la majoe (maemo) a hlophisitsoeng ka tatellano ea ho nyoloha, etsa qeto ea hore na frog e ka tšela nōka ka ho lula holim'a lejoe la ho qetela ( index ea ho qetela ea sehlopha). Qalong, senqanqane se holim'a lejoe la pele mme ...

Bala haholoanyane

Potso ea 6. Haha Array From Permutation Leetcode Tharollo Polelo ea Bothata The Build Array From Permutation LeetCode Solution - "Build Array From Permutation" e bolela hore ho fanoe ka lipalo tsa tumello tse thehiloeng ho zero, re tlameha ho haha ​​​​lethathamo la bolelele bo lekanang moo ans[i] = nums[nums[i]] bakeng sa e 'ngoe le e 'ngoe. ke sebakeng [0,nums.length-1]. Lipalo tsa tumello tse thehiloeng ho zero ke palo e fapaneng e fapaneng ho tloha ho 0 ...

Bala haholoanyane

Potso ea 7. Theko e tlase ea Litekete Tharollo ea Leetcode Phatlalatso ea Bothata Chelete e Bonyane bakeng sa Litekete Tharollo ea LeetCode - "Bonyane Chelete ea Litekete" e u kopa hore u fumane bonyane ba lidolara tseo u li hlokang ho tsamaea letsatsi le leng le le leng lethathamong le fanoeng la matsatsi. U tla fuoa palo e felletseng ea matsatsi. Letsatsi le leng le le leng ke palo e felletseng ho tsoa ho ...

Bala haholoanyane

Potso ea 8. Litsela Tse Ikhethang II Tharollo ea Leetcode Tlhaloso ea Bothata Litsela Tse Ikhethang II Tharollo ea LeetCode - "Litsela tse Ikhethang II" li bolela hore ho fanoe ka marang-rang a mxn moo roboto e qalang ho tloha ka holimo ho le letšehali la marang-rang. Re hloka ho fumana palo eohle ea litsela tsa ho fihla sekhutlong se ka tlase se letona sa marang-rang. ...

Bala haholoanyane

Potso ea 9. Batla Tharollo ea 2D Matrix II Leetcode Polelo ea Bothata Batla Tharollo ea 2D Matrix II LeetCode - "Batla 2D Matrix II" e u kopa ho fumana algorithm e sebetsang hantle e batlang sepheo sa boleng ho mxn integer matrix matrix. Linomoro moleng o mong le o mong, hammoho le kholomo, li hlophisoa ka tatellano e nyolohang. Mohlala: Kenyo: matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24, 18,21,23,26,30],[5]], target = XNUMX Sephetho: nnete ...

Bala haholoanyane

Potso ea 10. Karolelano ea ho falla ho tsoa ho Tharollo ea Leetcode ea Data Stream Phatlalatso ea Bothata Karolelano e Tsoang ho tloha Data Stream LeetCode Tharollo - "Moving Average from Data Stream" e bolela hore ho fanoe ka palo ea li-integers le boholo ba fensetere k. Re hloka ho bala karolelano e tsamaeang ea linomoro tsohle tse fensetereng e thellang. Haeba palo ea likarolo ho ...

Bala haholoanyane

Potso ea 11. Beha Tharollo ea Leetcode ea Matrix Zeroes Polelo ea Bothata The Set Matrix Zeroes LeetCode Solution – “Set Matrix Zeroes” e bolela hore u filoe mxn integer matrix. ho ea 0. U tlameha ho e etsa ka ...

Bala haholoanyane

Potso ea 12. Tharollo ea Leetcode ea Nomoro e sieo Phatlalatso ea Bothata Tharollo ea Nomoro e Fokohileng ea LeetCode - "Nomoro e sieo" e bolela hore ho fanoe ka palo ea boholo ba n e nang le linomoro tse fapaneng pakeng tsa [0,n]. Re hloka ho khutlisa nomoro e sieo sebakeng sa marang-rang. Mohlala: Input: nums = [3,0,1] Output: 2 Tlhaloso: Re ka hlokomela ha bonolo hore tsohle ...

Bala haholoanyane

Potso ea 13. Phunya Tharollo ea Letoto la Leetcode Bothata ba ho Sokisa Array Leetcode Solution bo re fa bolelele ba bolelele ba 2n. Mona 2n e bolela hore bolelele ba bolelele bo lekana. Ka mor'a moo re bolelloa hore re qhekelle sehlopha. Mona ho sisinyeha ha ho bolele hore re hloka ho hlophisa lethathamo ka mokhoa o ikhethileng empa tsela e ikhethang ke ...

Bala haholoanyane

Potso ea 14. Tharollo ea 3Sum Leetcode Polelo ea Bothata Ho fanoe ka linomoro tse ngata, na ho na le likarolo a, b, c ka li-nums joalo ka hore a + b + c = 0? Fumana li-triplets tsohle tse ikhethileng ka har'a sehlopha se fanang ka kakaretso ea zero. Tlhokomeliso: hore tharollo e se ke ea ba le mafahla a mararo. Mohlala # 1 [-1,0,1,2, -1,4] ...

Bala haholoanyane

Potso ea 15. Motsoako oa Tharollo ea Leetcode Bothata ba Combination Sum Leetcode Solution bo re fa lethathamo kapa lenane la linomoro le sepheo. Re bolelloa hore re fumane metsoako e ka etsoang ho sebelisa linomoro tsena ka makhetlo a mang le a mang a eketsang sepheo se fanoeng. Ka mokhoa o fetisisang, re ka sebelisa se fanoeng ...

Bala haholoanyane

Potso ea 16. Tharollo ea Leepcode ea Island Perimeter Polelo ea Bothata Bothateng bona, re fuoa gridi ka sebopeho sa sehlopha sa 2-D. grid [i] [j] = 0 e emela hore ho na le metsi ka nako eo mme grid [i] [j] = 1 e emela mobu. Lisele tsa grid li hokahane ka tsela e emeng / e tsepameng empa e se ka tsela e kopaneng. Ho na le sehlekehleke se le seng hantle (karolo e hokahaneng ea mobu ...

Bala haholoanyane

Potso ea 17. Boholo ba Tlatsetso ea Leetcode Tharollo Polelo ea Bothata Ha u fuoa linomoro tse ngata tse fapaneng, fumana sehlahisoa se kopaneng (se nang le bonyane palo e le 'ngoe) se nang le palo e kholo ka ho fetisisa ebe se khutlisa kakaretso ea sona. Mohlala nums = [-2,1, -3,4, -1,2,1, -5,4] 6 Tlhaloso: [4, -1,2,1] e na le kakaretso e kholo ka ho fetisisa = 6. nums = [- 1] -1 Atamela 1 (Arola le ho Hlōla) Ka mokhoa ona ...

Bala haholoanyane

Potso ea 18. Nako e nyane ea ho etela tharollo ea lintlha tsohle tsa Leetcode Bothata ba Nako e Nyane ea ho Etela Lintlha Tsohle Leetcode Solution e re fa lethathamo kapa vector ea lintlha ka lilepe tse hokahanyang. Bothata kamora ho re fa maikutlo re kopa hore re fumane nako e tlase ea ho etela lintlha tsohle tse fanoeng. Ha o tsamaisa yuniti e le 'ngoe ...

Bala haholoanyane

Potso ea 19. Bonyane ba Phapang e Felletseng ea Leetcode Tharollo Bothata ba Minimum Absolute Difference Leetcode Solution bo re fa lethathamo le sa hlophisoang kapa vector e nang le linomoro tse ling. Re kopuoa ho fumana lipara tsohle tse nang le phapang e lekanang le ea bonyane ba phapang e felletseng. Phapang e nyane ka ho fetesisa ke boleng bo tlase ba phapang e felletseng e ka ...

Bala haholoanyane

Potso ea 20. Fumana Tharollo ea Batho ba Tloaelehileng ea Leetcode Polelo ea Bothata Bothateng bona, re fuoa likhoele tse ngata. Re hloka ho hatisa lethathamo la litlhaku tsohle tse hlahang khoeleng e 'ngoe le e' ngoe ka har'a lethathamo (likopi li kenyelelitsoe). Ke hore ha sebopeho se hlaha makhetlo a mabeli khoeleng e ngoe le e ngoe, empa eseng makhetlo a 2, re hloka ho ba le eona ...

Bala haholoanyane

Potso ea 21. Fumana Linomoro Tsohle Tse Nyametseng ka Tharollo ea Leetcode Tharollo Polelo ea Bothata bothateng bona, re fuoa mefuta e mengata ea linomoro. E na le likarolo tse tsoang ho 1 ho ea ho N, moo N = boholo ba sehlopha. Leha ho le joalo, ho na le likarolo tse ling tse nyametseng mme tse ling tsa likopi li teng sebakeng sa tsona. Morero oa rona ke ho khutlisa sehlopha ...

Bala haholoanyane

Potso ea 22. Tharollo ea Leetcode ea bongata ba Element II Bothateng bona, re fuoa mefuta e mengata ea linomoro. Morero ke ho fumana likarolo tsohle tse etsahalang ho feta nako ea /N / 3⌋ ka bongata moo N = boholo ba sehlopha le ⌊ ⌋ e leng mosebeletsi oa mokatong. Re hloka ho khutlisa mefuta e mengata ea ...

Bala haholoanyane

Potso ea 23. Tharollo e Ikhethileng ea Leetcode Tharollo Bothata ba Unique Paths Leetcode Solution e re o filoe linomoro tse peli tse emelang boholo ba gridi. Ho sebelisa boholo ba gridi, bolelele le bophara ba gridi. Re hloka ho fumana palo ea litsela tse ikhethang ho tloha k'honeng e kaholimo ho le letšehali la gridi ho ea ...

Bala haholoanyane

Potso ea 24. Linomoro tse kae li nyane ho feta tharollo ea nomoro ea Leetcode Polelo ea Bothata Bothateng bona, re fuoa lethathamo. Bakeng sa karolo ka 'ngoe ea sehlopha sena, re tlameha ho fumana palo ea likaroloana tse nyane ho feta elemente eo. ke hore bakeng sa e mong le e i (0 <= i

Bala haholoanyane

Potso ea 25. Kopanya Tharollo ea Leetcode e hlophisitsoeng Bothateng ba "Merge Sorted Arrays", re fuoa mefuta e 'meli e hlophisitsoeng ka tatellano e sa theoheng. Sehlopha sa pele ha sea tlatsoa ka botlalo ebile se na le sebaka se lekaneng ho amohela likarolo tsohle tsa sehlopha sa bobeli. Re tlameha ho kopanya li-arrays tse peli, hore sehlopha sa pele se na le likarolo ...

Bala haholoanyane

Potso ea 26. Batla ka Tharollo ea Leetcode ea Arled Array Arched Nahana ka sehlopha se hlophisitsoeng empa ho ile ha khethoa index e le 'ngoe' me sehlopha sa potoloha ka nako eo. Joale, hang ha sehlopha se se se potolohiloe ho hlokahala hore u fumane ntho e ikhethileng ebe u khutlisa index ea eona. Haeba ho joalo, elemente ha e eo, khutla -1. Bothata ka kakaretso ke ...

Bala haholoanyane

Potso ea 27. Batla Kenya Tharollo Leetcode Tharollo Bothateng bona, re fuoa mefuta e hlophiloeng le palo e lebisitsoeng. Re tlameha ho fumana Search Insert Position. Haeba boleng ba sepheo bo le teng ka bongata, khutlisa index ea eona. Khutlisa index eo sepheo se lokelang ho kenngoa ho eona ho boloka tatellano e hlophisitsoe (ho ...

Bala haholoanyane

Potso ea 28. Bana ba nang le palo e kholo ka ho fetisisa ea tharollo ea lipompong Leetcode Bothateng ba "Bana ba nang le lipompong tse kholo ka ho fetesisa", re fuoa mefuta e mengata e emelang palo ea chokolete eo bana ba bang ba nang le eona le lipompong tse ling tse ka ajoang ka tsela efe kapa efe. Joale, re hloka ho fumana: Na ngoana e mong le e mong a ka ba le palo e kholo ka ho fetesisa ...

Bala haholoanyane

Potso ea 29. Ho matha Kakaretso ea 1d Array Leetcode Tharollo Polelo ea Bothata Ha re bala bothata ba lethathamo la 1d re fuoe lipalo tse ngata tseo re tlamehang ho li khutlisa moo bakeng sa index e 'ngoe le e' ngoe sephethong sa tatellano arr [i] = sum (nums [0]… nums [i]) . Mohlala nums = [1,2,3,4] [1,3,6,10] Tlhaloso: Kakaretso ea matha ke: ...

Bala haholoanyane

Potso ea 30. Fumana Boemo ba Pele le Bofelo ba Element ho Arged Array Leetcode Solution Polelo ea mathata Sehloohong sena se bitsitsoeng "Fumana Boemo ba Pele le Bofelo ba Element ho Sorted Array Leetcode Solution," re tla tšohla tharollo ea bothata ba leetcode. Bothateng boo re bo filoeng re fuoa lethathamo. Re boetse re fuoa sepheo sa sepheo. Lintho tse lenaneng li latellana ho ...

Bala haholoanyane

Potso ea 31. Tsela e Nyane ea Kakaretso ho Boraro-bo-bong Polelo ea Bothata Bothata "Tsela e Nyane ea Kakaretso ea Boraro-bo-bong" e re o fuoa tatellano ka sebopeho sa likhutlo-tharo tsa linomoro. Joale ho qala ka mola o kaholimo, ke bokae bonyane boo u ka bo fihlelang ha o fihla moleng o ka tlase? Mohlala 1 2 3 5 ...

Bala haholoanyane

Potso ea 32. Bolelele ba sejana se seholohali se nang le likarolo tse ikopantseng Bothata "Bolelele ba subarray e kholo ka ho fetisisa e nang le likarolo tse ikopantseng" e re o fuoe lenane le le leng. Polelo ea bothata e kopa ho fumana bolelele ba sehlopha se selelele ka ho fetesisa sa likarolo tse ka hlophisoang ka tatellano (e tsoelang pele, ekaba ea nyoloha kapa e theoha). Linomoro ho ...

Bala haholoanyane

Potso ea 33. Nako e molemohali ea ho reka le ho rekisa setoko Polelo ea Bothata Bothata "Nako e Ntle ea ho Reka le ho Rekisa Li-stock" e re o fuoe lethathamo la litheko tsa bolelele n, moo karolo eo e bolokang theko ea setoko ka letsatsi leo. Haeba re ka etsa khoebo e le 'ngoe feela, ke hore, ho reka ka letsatsi le le leng ...

Bala haholoanyane

Potso ea 34. Likarolo tsa khafetsa tsa K tse holimo Polelo ea Bothata Linthong tse holimo tsa K khafetsa re fane ka li-num tse ngata [], fumana likarolo tsa k tse etsahalang khafetsa. Mehlala nums [] = {1, 1, 1, 2, 2, 3} k = 2 1 2 nums [] = {1} k = 1 1 Mokhoa o se nang tsebo bakeng sa Lihaha tsa Khafetsa tsa K tse Holimo ...

Bala haholoanyane

Potso ea 35. Nako e nyane e hlokahalang ho bola lilamunu tsohle Polelo ea Bothata Bothata "Nako e nyane e hlokahalang ho bola lilamunu tsohle" e re o fuoe sehlopha sa 2D, sele e ngoe le e ngoe e na le e 'ngoe ea litekanyetso tse tharo tse ka bang 0, 1 kapa 2. 0 e bolela sele e se nang letho. 1 e bolela lamunu e ncha. 2 e bolela lamunu e bolileng. Haeba se bolileng ...

Bala haholoanyane

Potso ea 36. E hlophisitsoe ka tatellano ho ea ho Banced BST Ka tatellano e hlophisitsoeng ho ba le bothata bo leka-lekaneng ba BST, re fane ka tatellano ka tatellano, re aha Balanced Binary Search Tree ho tloha ho arotsoe. Mehlala Input arr [] = {1, 2, 3, 4, 5} Tlhahiso-pele ea tlhahiso: 3 2 1 5 4 Input arr [] = {7, 11, 13, 20, 22, ...

Bala haholoanyane

Potso ea 37. Mokhoa o tlase oa Leetcode Bothateng ba Subset Leetcode re fane ka li-integer, li-num, ho hatisa li-subsets tsohle (sete ea motlakase). Tlhokomeliso: Tharollo e behiloeng ha ea lokela ho ba le likopi tse tlase. Sehlopha A ke setlhopha sa mofuta oa B haeba ho ka fumanoa ho B ka ho hlakola tse ling (mohlomong, zero ...

Bala haholoanyane

Potso ea 38. Puputso ea Lentsoe Patlo ea mantsoe ke ntho e kang malepa a ho fumana mantsoe ka nako e 'ngoe bophelong ba rona. Kajeno ke tlisa tafoleng poleloana e fetotsoeng. Babali ba ka ba tlameha ho makala hore na ke bua ka eng. Ntle le ho senya nako, a re fihleng polelong ea mathata Re ka ...

Bala haholoanyane

Potso ea 39. Kenya Tlosa GetRandom Ho Kenyeletsa Tlosa bothata ba GetRandom re hloka ho rala sebopeho sa data se ts'ehetsang lits'ebetso tsohle tse latelang ka nako ea O (1). kenya (val): E kenya ntho val ho sete haeba e se e ntse e le teng. tlosa (val): E tlosa ntho ea boleng ho sete haeba e le teng. getRandom: E khutlisa ntho e sa reroang ho tloha sethaleng sa hona joale ...

Bala haholoanyane

Potso ea 40. Kopanya Likhaohano tse Kopaneng Ha re kopanya bothata ba linako tse lekanang re fane ka pokello ea linako, kopanya le ho khutlisa linako tsohle tse lekanang. Kenyelletso ea Mohlala: [[2, 3], [3, 4], [5, 7]] Sephetho: [[2, 4], [5, 7]] Tlhaloso: Re ka kopanya [2, 3] le [3 , 4] hammoho ho theha [2, 4] Mokhoa oa ho fumana Merge ...

Bala haholoanyane

Potso ea 41. Bohareng ba mefuta e 'meli e hlophisitsoeng E fuoe mefuta e 'meli e arotsoeng A le B ea boholo n le m ka ho latellana. Fumana karolo e bohareng ea sehlopha sa ho qetela se hlophiloeng kamora ho kopanya likarolo tse peli tse fanoeng kapa ka mantsoe a mang, re re fumana mefuta e 'meli e arotsoeng. (Ho rarahana ha nako e lebelletsoeng: O (log (n))) Atamela 1 bakeng sa ...

Bala haholoanyane

Potso ea 42. Boholo ba Sehlahisoa sa Sehlahisoa Bothateng bo boholo ba lihlahisoa tse nyane tsa lihlahisoa, re fane ka palo e felletseng ea linomoro, fumana sehlopha se kopaneng se nang le atleast element e le 'ngoe e nang le sehlahisoa se seholo ka ho fetisisa. Mohlala Arr = [0, -1, 0, 1, 2, -3] Boholo ba sehlahisoa = 2 Arr = [- 1, -1, -1] Boholo ba sehlahisoa = -1 Arr = [0, -1, 0, - 2, 0] ...

Bala haholoanyane

Potso ea 43. Batla Element ho Lenane la Rotated Array Ha re ntse re batlana le bothata bo hlophisitsoeng bo hlophisitsoeng re fane ka mofuta o hlophisitsoeng le o potolohileng le ntlha, sheba hore na karolo e fanoeng e teng ka har'a sehlopha kapa che. Mehlala Linomoro tsa ho kenya linomoro [] = {2, 5, 6, 0, 0, 1, 2} target = 0 Ho hlahisa linomoro tsa 'nete tsa ho kenya [] = {2, ...

Bala haholoanyane

Potso ea 44. Boholo ba Sehlahisoa sa Sehlahisoa Ha u fuoa mefuta e mengata ea linomoro, fumana sehlahisoa se phahameng ka ho fetisisa se fumanoeng ho tsoa ho karolo e nyane ea sehlopha se fanoeng. Mehlala Keketso ea ho kenya [] = {-2, -3, 0, -2, -40} Tlhahiso ea 80 Input arr [] = {5, 10, 6, -2, 1} Khumo ea 300 Input arr [] = {-1 , -4, -10, 0, 70} Khumo 70 ...

Bala haholoanyane

Potso ea 45. 3 Kakaretso Mathateng a 3 a Sum, re fane ka li-num tse ngata, fumana li-triplets tsohle tse ikhethileng tse akaretsang ho fihlela ho 0. Mohlala Input: nums = {-1, 0, 1, 2, -1, -4} Sephetho: { -1, 0, 1}, {-1, 2, -1} Mokhoa o se nang kelello bakeng sa bothata ba 3 Sum Mokhoa oa matla a Brute ...

Bala haholoanyane

Potso ea 46. Fumana Nomoro ea Mafahla Ha ho fanoa ka li-num tse ngata tse nang le likarolo tsa (n + 1) mme ntho e ngoe le e ngoe e pakeng tsa 1 ho isa ho n. Haeba ho na le elemente e le 'ngoe feela e kopilitsoeng, fumana linomoro tse kopilitsoeng. Mehlala Input: nums = {1, 3, 4, 2, 2} Output: 2 Input: nums = {3, 1, 3, 4, 2} Output: 3 Naive ...

Bala haholoanyane

Potso ea 47. Bonyane ba Tsela Sum Bothateng bo tlase ba kakaretso ea tsela, re file "a × b" matrix e nang le linomoro tse seng mpe. Mosebetsi oa hau ke ho fumana tsela ho tloha kaholimo ho le letšehali ho ea tlase tlase e fokotsang kakaretso e nang le linomoro tsohle tse tlang tseleng eo u e fumaneng. Tlhokomeliso: U ka tsamaisa feela ...

Bala haholoanyane

Potso ea 48. Fumana lefahla Ha ho fanoa ka mefuta e mengata ea boholo ba n + 1 moo karolo e 'ngoe le e' ngoe ea sehlopha e pakeng tsa 1 le n (ho kenyelelitsoe), ho na le ntho e le 'ngoe e kopitsoang ka har'a sehlopha, fumana karolo e kopitsoang. Mokhoa oa matla a Brute - Atamela 1 bakeng sa ho fumana lefahla bakeng sa ntho e ngoe le e ngoe e sebetsang ...

Bala haholoanyane

Potso ea 49. Tharollo ea LeetCode ea Metsi a ho Tlisa Pula Bothateng ba LeetCode ea Metsi a Trapping Rain Water, re fane ka linomoro tsa N non-negative tse emelang 'mapa oa bophahamo 'me bophara ba bar e' ngoe le e 'ngoe ke 1. Re tlameha ho fumana bongata ba metsi a ka qabelloang mohahong o ka holimo. Mohlala Ha re utloisise hore ka mohlala Bakeng sa ...

Bala haholoanyane

Potso ea 50. Papali ea Jump Papaling ea ho qhomela re fane ka lethathamo la linomoro tse seng mpe, o qalong o behiloe lenaneng la pele la sehlopha. Karolo e 'ngoe le e' ngoe ea sehlopha e emetse bolelele ba hau ba ho tlola boemong boo. Etsa qeto ea hore na u khona ho fihlela index ea ho qetela. Keletso ea Mohlala: arr = [2,3,1,1,4] ...

Bala haholoanyane

Potso ea 51. Motswako Sum Ha re kopanya mathata re fane ka mefuta e mengata ea linomoro tse nepahetseng arr [] le kakaretso s, fumana mefuta eohle e ikhethang ea likarolo ho arr [] moo kakaretso ea likarolo tseo e lekanang le s. Nomoro e ts'oanang e phetoang e kanna ea khethoa ho arr [] palo e sa lekanyetsoang ea makhetlo. Lintho ...

Bala haholoanyane

Potso ea 52. Sebaka sa Max Island Tlhaloso ea Bothata: Ha ho fanoa ka matrix a 2D, matrix e na le 0 feela (e emelang metsi) le 1 (e emelang mobu) joalo ka litlatsetso. Sehlekehleke se matrix se theoa ka ho hlopha lihlopha tsohle tse haufinyane tsa 1 tse hokahantsoeng ka 4 (ka mokhoa o otlolohileng le o otlolohileng). Fumana sebaka se phahameng sa sehlekehleke ka har'a matrix. Nka hore likarolo tsohle tse 'ne tsa ...

Bala haholoanyane

Potso ea 53. Batla ka Lethathamong le hlophisitsoeng la Rotated Patlo ea likarolo ka tatellano e hlophiloeng e potolohileng e ka fumanoa ho sebelisoa patlo ea binary ka nako ea O (logn). Morero oa poso ena ke ho fumana ntho e fanoeng ka tatellano e hlophisitsoeng ka nako ea O (logn). Ho fanoa ka mohlala o mong oa mofuta o hlophisitsoeng o hlophisitsoeng. Keletso ea Mohlala: arr [] = {7,8,9,10,1,2,3,5,6}; ...

Bala haholoanyane

Potso ea 54. Litsela Tse Ikhethileng Ho fanoa ka gridi ea mxn 2D 'me u eme kaholimo ho sele le ka ho le letšehali ho grid. ke hore sele e fumanehang ho (1,1). Fumana palo ea litsela tse ikhethileng tse ka nkuoang ho fihlela sele e fumanehang ho (m, n) ho tloha seleng e fumanehang ho (1,1) ...

Bala haholoanyane

Potso ea 55. Boholo ba Subarray Mathateng a Maximum Subarray re fane ka li-num tse ngata tse fapaneng, fumana sehlopha se kopaneng se nang le kakaretso e kholo ebe o printa boholo ba boleng ba karolelano. Mohlala oa ho kenya linomoro [] = {-2, 1, -3, 4, -1, 2, 1, -5, 4} Output 6 Algorithm Morero ke ho fumana ...

Bala haholoanyane

Potso ea 56. Ho kopanya Likarolo Ha re kopanya likhaohano mathata re fane ka sete ea linako tsa sebopeho [l, r], kopanya likarolo tse tlamang. Keketso ea Mehlala {[1, 3], [2, 6], [8, 10], [15, 18]} Sephetho {[1, 6], [8, 10], [15, 18]} Keletso 1, 4], [1, 5]} Sephetho {[1, 5]} Mokhoa o se nang tsebo oa ho kopanya likarolo ...

Bala haholoanyane

Potso ea 57. Fumana Peak Element Ha re utloisiseng Fumana bothata ba Peak Element. Kajeno re na le sehlopha se hlokang tlhoro ea sona. Joale, o tlameha o be o ntse o ipotsa hore na ke bolelang ka ntlha ea tlhoro? Karolo ea tlhoro ke e kholo ho feta baahisani bohle ba eona. Mohlala: Ho filoe lethathamo la ...

Bala haholoanyane

Potso ea 58. Nomoro ea Triangle e sebetsang Bothata Bothateng ba Nomoro ea Triangle e Loketseng, re fane ka mefuta e mengata ea linomoro tse seng mpe. Fumana palo ea li-triplets tse ka etsang triangolo. Haeba re nahana ka linomoro tse lenaneng le bolelele ba mahlakore a mararo. Kakanyo ea Mohlala [2, 2, 3, 4] Tlhaloso ea 3 Tlhaloso Re ...

Bala haholoanyane

Potso ea 59. Kopanya Array Array Ha re kopanya bothata bo hlophisitsoeng re hlophisitse likarolo tse peli tse hlophiloeng ka tatellano e ntseng e eketseha. Ha re kenya letsoho pele, re fane ka palo e qalileng ho ar1 le array2. Linomoro tsena tse peli ke N le M. Boholo ba array1 bo lekana le kakaretso ea N le M. Ka tatellano ea 1 pele ...

Bala haholoanyane

Potso ea 60. Setshelo le Metsi a mangata Tlhaloso ea bothata: u fuoa linomoro tse ngata (y0, y1, y2… yn-1) ho li-indices (i = 0,1,2… n-1). Kakaretso ea index ea i-th ke yi. Joale, u hula mela ka sefofaneng sa mochini o mong le o mong o hokahanyang (i, yi) le (i, 0). Fumana boholo ba metsi ...

Bala haholoanyane

Potso ea 61. Kakaretso ea Likarolo tse lekana le k Ho fanoe ka palo e felletseng le kakaretso k. Fumana palo e felletseng ea litapole tse tsamaellanang tsa sehlopha se fanoeng seo likarolo tsa sona li lekanang le k. Mohlala Keletso 1: arr [] = {5,0,5,10,3,2, -15,4} k = 5 Output: 7 Input 2: arr [] = {1,1,1,2,4, -2} k = 2 Sephetho: Tlhaloso e 4: nahana ka mohlala-1 ...

Bala haholoanyane

Potso ea 62. Bothata ba Phetoho ea Chelete ea tšepe Bothata ba Phetoho ea Chelete ea Chelete - Ho fanoe ka lichelete tsa tšepe tsa boleng bo fapaneng c1, c2,…, cs (Mohlala: 1,4,7….). Re hloka palo n. Sebelisa licheleteng tsena tsa tšepe ho etsa chelete n. U ka sebelisa chelete ea tšepe makhetlo a mangata kamoo ho hlokahalang. Fumana palo eohle ea litsela tseo ka tsona ...

Bala haholoanyane

Potso ea 63. Fumana bonyane ba Element ka tatellano e hlophisitsoeng le e potolohileng Polelo ea Bothata Bothateng ba "Fumana Bonyane ba Element ho Lethathamo le Hlophisitsoeng" re fane ka lethathamo le hlophisitsoeng []. Sehlopha sena se potoloha ka nako e sa tsejoeng, fumana bonyane ba karolo ea sehlopha sena. Fomate ea ho kenya Inline ea pele ebile e le 'ngoe feela e nang le boleng bo boholo ba n. ...

Bala haholoanyane

Potso ea 64. Kopanya Likhaohano tse Kopaneng II Polelo ea Bothata Bothateng ba "Kopanya Likarohano tse Kopaneng tsa Bobeli" re fane ka sete ea linako. Ngola lenaneo le tla kopanya mekhahlelo e kenang ho e le ngoe ebe o hatisa linako tsohle tse sa lekanang. Fomate ea ho kenya Mohala oa pele o nang le palo e kholo n. Mohala oa bobeli o nang le lipara moo para ka 'ngoe e leng ...

Bala haholoanyane

Potso ea 65. Boholo ba Subarray Sum bo sebelisa Karohano le ho Hlōla Polelo ea Bothata Bothateng ba "Maximum Subarray Sum e sebelisang Divide le Conquer" re fane ka lethathamo la linomoro tse ntle le tse mpe. Ngola lenaneo le tla fumana kakaretso e kholo ka ho fetisisa ea karoloana e ikhethileng. Fomate ea ho Kena Mohala oa pele o nang le palo e kholo ea N. Mohala oa bobeli o nang le pokello ea ...

Bala haholoanyane

Potso ea 66. Ts'ebetso ea Iterative ea Mofuta o Potlakileng Polelo ea Bothata Bothateng ba "Ts'ebetsong ea Ts'ebetso ea Mofuta o Potlakileng", re fane ka letoto le []. Re tlameha ho hlophisa lethathamo re sebelisa mofuta o potlakileng. Mona, mofuta o potlakileng ha o sebelisoe khafetsa, o etsoa ka mokhoa oa ho pheta-pheta. Fomate ea ho kenya Mohala oa pele o nang le palo e kholo n. Mohala oa bobeli o nang le ...

Bala haholoanyane

Potso ea 67. Phunya lenane le fanoeng Polelo ea Bothata Bothateng ba "Shuffle a Array Array" re fane ka palo ea linomoro. Ngola lenaneo le hlakolang sehlopha se fanoeng. Ka mantsoe a mang, e tla hlakola likarolo tse fapaneng ka tatellano. Fomate ea ho kenya Mohala oa pele o nang le palo e kholo n. Mohala oa bobeli o nang le tlhahiso e kholo e arohaneng ea sebaka ...

Bala haholoanyane

Potso ea 68. Ho hlophisa mofuta o hlophisitsoeng oa K Polelo ea Bothata Bothateng ba "Ho hlophisa K Arged Array" re fane ka mefuta e mengata ea likarolo, moo karolo e ngoe le e ngoe e leng k haholo hole le boemo ba eona. Rala algorithm e fapaneng ka nako ea O (n logi k). Fomate ea ho Kena Mohala oa pele o nang le litekanyetso tse peli tse lekanang N ...

Bala haholoanyane

Potso ea 69. Boholo ba Sehlahisoa sa Sehlahisoa II Polelo ea Bothata Bothateng ba "Maximum Product Subarray II" re fane ka lethathamo le nang le linomoro tse nepahetseng, tse fosahetseng, le linotši. Re hloka ho fumana sehlahisoa se phahameng sa subarray. Fomate ea ho kenya Mohala oa pele o nang le palo e kholo ea N. Mohala oa bobeli o nang le linomoro tse arohaneng tsa sebaka sa N. Sebopeho sa Khumo Ke sona feela ...

Bala haholoanyane

Potso ea 70. Palo e kahodimodimo ea Kakaretso ea Keketseho Polelo ea Bothata Bothateng ba "Boholo bo Eketsehileng ba Kakaretso" re fane ka letoto. Fumana kakaretso ea boholo ba tatellano e fanoeng, ke hore linomoro tse latelang li hlophisitsoe ka tatellano. Ketsahalo e latelang ke karolo ea tatellano eo e leng tatellano eo e leng ...

Bala haholoanyane

Potso ea 71. Palo ea likaroloana tse nyane ka lehlakoreng le letona Polelo ea Bothata Bothateng ba "Palo ea Lintho tse Nyane ka lehlakoreng le Letona", re fane ka letoto []. Fumana palo ea likaroloana tse nyane tse ka lehlakoreng le letona la lehlakoreng le leng le le leng. Fomate ea Input Mohala oa pele le o le mong feela o nang le palo e kholo ea N. Mohala oa bobeli o nang le linomoro tse arohaneng tsa sebaka sa N. Khumo ...

Bala haholoanyane

Potso ea 72. Lintho li hlaha ka makhetlo a fetang N / K ho Array Polelo ea Bothata Bothateng ba "Elements bo hlaha ho feta makhetlo a N / K ho Array" re fane ka bongata bo boholo ba n. Fumana lintlha tse hlahang makhetlo a fetang n / k. Moo k ke boleng ba ho kenya. Sebopeho sa Input Mohala oa pele mme e le 'ngoe feela o nang le linomoro tse peli tsa N le ...

Bala haholoanyane

Potso ea 73. Fumana Peak Element ho tsoa Lenaneng Polelo ea Bothata Bothateng ba "Fumana Peak Element ho tsoa ho Lenane" re fane ka palo ea linomoro. Fumana ntlha e phahameng. Ka bongata, elemente ke ntlha ea tlhoro, haeba elemente e le kholo ho feta baahelani ka bobeli. Bakeng sa likarolo tsa sekhutlo, re ka nahana ka eona feela ...

Bala haholoanyane

Potso ea 74. Beakanya lipalo tse ntle le tse fosahetseng ka tsela e 'ngoe ho Array Polelo ea Bothata Bothateng ba "Hlophisa Linomoro Tse Ntle le Tse Fosahetseng ka Tsela e 'Ngoe ka Tsela" re fane ka letoto le []. Sehlopha sena se na le linomoro tse nepahetseng le tse fosahetseng. Beakanya lintho ka bongata ka tsela ea hore tse ntle le tse mpe li beoe ka tsela e ngoe. Mona, palo ea likarolo tse ntle le tse mpe ha e hloke ...

Bala haholoanyane

Potso ea 75. Fumana Palo e Phethahetseng e Phethahetseng ho Array Polelo ea Bothata Bothateng ba "Fumana Palo e Phethahetseng e Phethahetseng ka Lethathamo" re fane ka mefuta e sa lekanyetsoang ea boholo N. Re filoe mefuta e mengata e nang le linomoro tsa {0, k} moo k <= N. Fumana nomoro e tlang ka palo e holimo ea linako tse ngata ka tatellano. Sebopeho sa Input The ...

Bala haholoanyane

Potso ea 76. Lintlha tse 'ne tseo re lokelang ho li fuoa Polelo ea Bothata Linthong tse 'ne tse akaretsang bothata bo fanoeng, re fane ka sehlopha se nang le likarolo tsa N tse ka bang ntle kapa tse mpe. Fumana sete ea likarolo tse 'ne tseo kakaretso ea tsona e lekanang le boleng bo fuoeng k. Fomate ea Input Mohala oa pele o nang le palo e kholo ea N. Mohala oa bobeli o nang le tatellano ...

Bala haholoanyane

Potso ea 77. Bothata ba ho arola Polelo ea Bothata Bothateng ba karohano, re fane ka sete e nang le lintho tsa n. Fumana hore na sete e fanoeng e ka aroloa ka lihlopha tse peli tseo likarolo tsa eona li-subsets li lekanang. Mohlala Input arr [] = {4, 5, 11, 9, 8, 3} Output Yes Tlhaloso Lethathamo ...

Bala haholoanyane

Potso ea 78. Fumana sephetho sa boholo ba 3 Polelo ea Bothata Lethathamong le fuoeng la linomoro tse sa hlophisoang. Re hloka ho fumana tatellano e hlophisitsoeng ea boholo ba 3. A likarolo tse tharo e be tse hlophiloeng [i], array [j], array [k] ebe, array [i] <array [j] <array [k] for i <j < k. Haeba ho na le makhetlo a mararo a fumanoang ka har'a sehlopha, hatisa efe kapa efe ...

Bala haholoanyane

Potso ea 79. Subarray ka Kakaretso e fanoeng Polelo ea Bothata Karolong e ka tlase ea bothata bo fanoeng, re fane ka sehlopha se nang le likarolo tse ntle. Re tlameha ho fumana karoloana eo ho eona kakaretso ea likarolo tsohle tsa karoloana e lekanang le given_sum. Subarray e fumaneha ho tsoa ho sehlopha sa mantlha ka ho hlakola tse ling ...

Bala haholoanyane

Potso ea 80. Fumana karolo e lahlehileng ho tsoa ho lenane le kopitsitsoeng Polelo ea Bothata ha e fuoa likarolo tse peli tsa A le B, sehlopha se le seng ke lefahla le leng ntle le ntho e le 'ngoe. Karolo e le 'ngoe e haelloa ke A kapa B. re hloka ho fumana ntho e lahlehileng ho tsoa lenaneng le kopilitsoeng. Mohlala 5 1 6 4 8 9 6 4 8 ...

Bala haholoanyane

Potso ea 81. Lokisetsa bocha lenane le fuoeng boholo bo tlase Polelo ea Bothata Bothateng ba "Rearange Array in Maximum Minimum Form" bothata, re fane ka sehlopha se hlophisitsoeng se nang le likarolo tsa N. Beakanya botjha mefuta e felletseng ya dinomoro tse nepahetseng, hore dikarolo tse ding di be max le min min. Sheba ka tlase bakeng sa kutloisiso e betere ea ho hlophisoa bocha ha likarolo- Array [0] ...

Bala haholoanyane

Potso ea 82. Kopanya Lisebelisoa tse peli tse hlophisitsoeng Polelo ea Bothata Ho kopanya mathata a mabeli a hlophisitsoeng, re fane ka lintlha tse peli tse hlophisitsoeng tse kentsoeng, re hloka ho kopanya likarolo tsena tse peli hore linomoro tsa pele kamora ho hlopha ka botlalo li be sehlopheng sa pele mme li lule sehlopheng sa bobeli. Keletso ea Mohlala A [] = {1, 3, 5, 7, ...

Bala haholoanyane

Potso ea 83. Palo ea Boraro-bo-bong e nang le Kakaretso e ka tlase ho Boleng bo Fuoeng Polelo ea Bothata Re fane ka lenane le nang le linomoro tsa N tse ngata. Lethathamong le fanoeng, bala palo ea mafahla a mararo ka chelete e ka tlase ho boleng bo fanoeng. Ho kenya mohlala a [] = {1, 2, 3, 4, 5, 6, 7, 8} Kakaretso = Liphetho tse 10 Tse ka bang teng tse tharo tse tharo ke tsena: ...

Bala haholoanyane

Potso ea 84. Element e kholo e latelang ka tatellano Polelo ea Bothata Ha re fuoa lethathamo, re tla fumana karolo e latelang e kholo ea ntlha ka 'ngoe ka tatellano. Haeba ho se na ntlha e latelang e kholo ea ntho eo re tla hatisa -1, ho seng joalo re tla e hatisa. Tlhokomeliso: Ntho e latelang e kholo ke ntho e kholo le ...

Bala haholoanyane

Potso ea 85. Ho kopanya mefuta e 'meli e hlophisitsoeng Polelo ea Bothata Ha re kopanya bothata ba lihlopha tse peli tse hlophisitsoeng re fane ka mefuta e 'meli e hlophisitsoeng, e' ngoe e nang le boholo ba m + n le e 'ngoe e nang le boholo n. Re tla kopanya mefuta e fapaneng ea n + m le n size array ebe re hatisa m + n boholo bo kopaneng. Mohlala Input 6 3 M [] = ...

Bala haholoanyane

Potso ea 86. Fumana Element U Sebelisa Patlo ea Binary ho Li Array Array Polelo ea Bothata Ha u fuoa lethathamo le hlophisitsoeng, Fumana element u sebelisa patlo ea binary ka har'a sehlopha se hlophisitsoeng. Haeba e le teng, hatisa index ea element element e ngoe print -1. Mohlala Input arr [] = {1, 6, 7, 8, 9, 12, 14, 16, 26, 29, 36, 37, 156} X = 6 // element e lokelang ho phenyekolloa ...

Bala haholoanyane

Potso ea 87. Fumana Triplet ka Lethathamo ka Kakaretso e Fuoeng Polelo ea Bothata Ha u fuoa mefuta e mengata ea linomoro, fumana motsoako oa likarolo tse tharo tsa lenane leo kakaretso ea lona e lekanang le boleng bo fanoeng X. Mona re tla hatisa motswako oa pele oo re o fumanang. Haeba ho se na kopano e joalo, hatisa -1. Ho kenya mohlala N = 5, X = 15 arr [] = ...

Bala haholoanyane

Potso ea 88. Fumana likopi ka tatellano ka tsela e sebetsang hantle Polelo ea Bothata Hlahisa likarolo tsohle tse etsahetseng ka tsela e sebetsang hantle ho feta ho O (n) le O (1). Ha ho fanoa ka boholo ba boholo ba n bo nang le linomoro ho tloha ho 0 ho ea ho n-1, linomoro tsena li ka hlaha makhetlo a mangata. Fumana likopi ka bongata ba tse sebetsang hantle ka ho fetesisa ...

Bala haholoanyane

Potso ea 89. Nomoro e nyane ka ho fetisisa e sieo ka tatellano e sa hlophisoang Polelo ea Bothata Lethathamong le fanoeng le sa hlophisoang fumana palo e nyane ka ho fetisisa e nepahetseng e le sieo ka tatellano e sa hlophisoang. Nomoro e nepahetseng ha e kenyeletse 0. Re ka fetola mefuta ea mantlha ha ho hlokahala. Sehlopha se ka ba le linomoro tse ntle le tse fosahetseng. Mohlala a. Lenane la ho kenya: [3, 4, -1, 0, -2, 2, 1, ...

Bala haholoanyane

Potso ea 90. Tlosa Zero Tsohle Qetellong ea Lenane le Fuoeng Polelo ea Bothata Lethathamong le fanoeng tsamaisa linoto tsohle tse teng ka har'a sehlopha ho fihlela qetellong. Mona ho lula ho na le mokhoa oa ho kenya linomoro tsohle ho isa qetellong ea sehlopha. Ho kenya mohlala 9 9 17 0 14 0 ...

Bala haholoanyane

Potso ea 91. Palo ea Palo ea Liketsahalo ka tatellano e hlophiloeng Polelo ea Bothata Bothateng ba "Palo ea Liketsahalo ka tatellano e hlophisitsoeng", re fane ka lethathamo le hlophisitsoeng. Bala palo ea liketsahalo kapa makhetlo a mangata ka tatellano ea X moo X e leng palo e kholo. Keletso ea mohlala 13 1 2 2 2 2 3 3 3 4 4 ...

Bala haholoanyane

Potso ea 92. Fumana palo e nyane ka ho fetisisa e sieo ka tatellano e hlophiloeng Polelo ea Bothata Bothateng ba "Fumana Ntho e Nyane ka ho Fetisisa e Fosahetseng ka tatellano e hlophisitsoeng" re fane ka lenane le le leng. Fumana nomoro e nyane ka ho fetisisa e sieo lenaneng le hlophisitsoeng ka boholo ba N le nang le likarolo tse ikhethileng ho 0 ho M-1, moo M> N. Ho kenya mohlala [0, 1, 2, 3, 4, 6, 7, ...

Bala haholoanyane

Potso ea 93. Ntho ea pele e pheta-phetoang Polelo ea Bothata Re fane ka lenane le nang le linomoro. Re tlameha ho fumana ntho ea pele e iphetang lethathamong le fanoeng. Haeba ho se na ntho e phetoang joale hatisa "Ha ho na palo e phetoang e fumanoeng". Tlhokomeliso: Lintho tse pheta-phetoang ke likarolo tse tlang hangata. (Lethathamo le kanna la ba le mafahla) ...

Bala haholoanyane

Potso ea 94. Sehlahisoa sa Array Puzzle Polelo ea Bothata Bothateng ba selotho se nang le lihlahisoa re hloka ho theha sehlopha moo karolo ea eona e tla ba sehlahisoa sa likarolo tsohle tse lenaneng le fanoeng ntle le karolo ea boemo ba eona. Keletso ea mohlala 5 10 3 5 6 2 Khumo 180 600 360 300 900 ...

Bala haholoanyane

Potso ea 95. Fumana lipara tsohle ka phapang e fanoeng Polelo ea Bothata Re fane ka letoto la lintho tse fapaneng kapa ha ho na lintho tse phetoang tse teng ka tatellano. Fumana lipara tsohle ka phapang e fanoeng. Haeba ho se na li-pair tse fanoeng ka mokhoa o fapaneng joale hatisa "Ha ho na li-pair tse fuoeng tse fapaneng". Keletso ea mohlala 10 20 90 70 20 80 ...

Bala haholoanyane

Potso ea 96. Fumana nomoro ea pele e iphetang ka tatellano e fanoeng Polelo ea Bothata Ho ka ba le linomoro tse pheta-phetoang tse ngata ka bongata empa u tlameha ho fumana nomoro ea pele e pheta-phetoang ka tatellano e fanoeng (e hlahang ka lekhetlo la bobeli). Keketso ea Mohlala 12 5 4 2 8 9 7 12 5 6 12 4 7 Khumo ea 5 ke ntho ea pele e iphetang ...

Bala haholoanyane

Potso ea 97. Boholo ba Element Polelo ea Bothata Ha re fuoa sehlopha se hlophisitsoeng, re hloka ho fumana likarolo tse ngata ho tsoa ho tse hlophisitsoeng. Boholo ba elemente: Nomoro e etsa palo e fetang halofo ea boholo ba sehlopha. Mona re fane ka nomoro x re tlameha ho e sheba hore na ke bongata_bo bongata kapa che. Mohlala Input 5 2 ...

Bala haholoanyane

Potso ea 98. Fumana Nomoro e Haellang Polelo ea Bothata Ha re fumana linomoro tse sieo ho tsoa lenaneng la linomoro tse 1 ho isa ho tse N re fane ka lethathamo le nang le linomoro tsa N-1. Nomoro e le 'ngoe ha e na palo ea linomoro ho tloha ho 1 ho ea ho N. Re tlameha ho fumana nomoro e sieo. Fomate ea Input Mohala oa pele o nang le palo e felletseng ...

Bala haholoanyane

Lipotso tsa Khoele ea Bloomberg

Potso ea 99. Tharollo ea Leetcode e Tloaelehileng e telele ka ho fetisisa Polelo ea Bothata The Longest Common Prefix LeetCode Solution - "Longest Common Prefix" e bolela hore ho fanoe ka mefuta e mengata ea likhoele. Re hloka ho fumana sehlongwapele se selelele ka ho fetisisa hara dikgwele tsena. Haeba ho se na sehlongoapele, khutlisetsa khoele e se nang letho. Mohlala: Kenyelletso: strs = ["palesa",,"phalla","sefofane"] Sephetho: "fl" Tlhaloso: "fl" ke e telele ka ho fetisisa ...

Bala haholoanyane

Potso ea 100. Tharollo e sebetsang ea Palindrome II ea Leetcode Phatlalatso ea Bothata Tharollo e Tiileng ea Palindrome II LeetCode - "Palindrome II e Tiileng" e bolela hore ho fanoe ka khoele s, re hloka ho khutlela 'nete haeba s e ka ba khoele ea palindrome ka mor'a ho hlakola boholo ba sebopeho se le seng. Mohlala: Kenyeletso: s = "aba" Sephetho: Tlhaloso ea 'nete: Khoele ea ho kenya e se e ntse e le palindrome, kahoo ho na le ...

Bala haholoanyane

Potso ea 101. Masakaneng a Sebetsang Tharollo ea Leetcode Polelo ea Bothata Tharollo ea LeetCode e Sebetsang - "Masakaneng a Tšepahalang" e re o fuoa khoele e nang le litlhaku feela '(', ')', '{', '}', '[' le ']'. Re hloka ho fumana hore na khoele ea ho kenya ke khoele e nepahetseng kapa che. Khoele ho thoe ke khoele e sebetsang haeba masakaneng a bulehileng a tlameha ho koaloa ...

Bala haholoanyane

Potso ea 102. Palindrome Partitioning Leetcode Tharollo Polelo ea Bothata Tharollo ea Palindrome Partitioning LeetCode - "Palindrome Partitioning" e re o fuoa khoele, arola khoele e le hore karolo e 'ngoe le e 'ngoe ea karohano e be palindrome. Khutlisetsa karohano eohle ea palindrome ea khoele e kenang. Mohlala: Kenyelletso: s = "aab" Sephetho: [["a","a","b"],["aa","b"]] Tlhaloso: Ho na le tse 2 hantle tse nepahetseng ...

Bala haholoanyane

Potso ea 103. Bala 'me u re Tharollo ea Leetcode Phatlalatso ea Bothata The Count and Say LeetCode Solution - "Bala 'me u bue" e u kopa hore u fumane nako ea nth ea tatellano ea ho bala le ho re. Tatellano ea ho bala le ho re ke tatelano ea likhoele tsa linomoro tse hlalosoang ka mokhoa o iphetang: countAndSay(1) = "1" countAndSay(n) ke tsela eo u ka "buang" khoele ea linomoro ho tloha countAndSay(n-1), e ntan'o fetoloa ...

Bala haholoanyane

Potso ea 104. Palindromic Substrings Leetcode Tharollo Polelo ea Bothata Tharollo ea LeetCode ea Palindromic Substrings - "Palindromic Substrings" e u kopa ho fumana palo e felletseng ea likhoele tse nyane tsa palindromic khoeleng ea ho kenya. Khoele ke palindrome ha e balla morao joalo ka pele. Substring ke tatelano e kopaneng ea litlhaku ka har'a khoele. Mohlala: Kenyo: s = "aaa" Sephetho: ...

Bala haholoanyane

Potso ea 105. Tlosa Masakaneng a Fosahetseng Tharollo ea Leetcode Polelo ea Bothata Tlosa Masakaneng a Fosahetseng Leetcode Tharollo - e bolela hore o fuoa likhoele tse nang le masaka le litlhaku tse nyane. Re hloka ho tlosa bonyane palo ea mashaka a sa sebetseng ho etsa hore mohala o sebetse. Re hloka ho khutlisa liphetho tsohle tse ka bang teng ka tatellano efe kapa efe. Khoele ke...

Bala haholoanyane

Potso ea 106. Bonyane ba Mehato ea ho Etsa Likhoele tse peli Anagram Leetcode Solutions Polelo ea Bothata Bothateng bona, re fuoa likhoele tse peli 's' & 't' tse nang le litlhaku tse tlase tsa Senyesemane. Ketsahalong e le 'ngoe, re ka khetha mofuta ofe kapa ofe ka khoele' t 'ebe re o fetisetsa ho motho e mong. Re hloka ho fumana palo e tlase ea ts'ebetso e joalo ho etsa 't' an ...

Bala haholoanyane

Potso ea 107. Arola khoele ka tharollo e leka-lekaneng ea Leetcode Polelo ea Bothata Bothateng bona, re fuoa lethathamo la litlhaku, tse nang le 'R' le 'L' feela. Re bitsa khoele e leka-lekaneng haeba e na le palo e lekanang ea 'R' le 'L'. Re ka arola khoele eo re e filoeng ka likaroloana tse sa kopaneng. Morero ke ho fumana palo e phahameng ka ho fetisisa e ka bang teng ...

Bala haholoanyane

Potso ea 108. Tharollo ea Isomorphic Strings Leetcode Polelo ea Bothata bothateng bona, re fuoa likhoele tse peli, a le b. Morero oa rona ke ho tseba hore na likhoele tse peli ke isomorphic kapa che. Likhoele tse peli li bitsoa isomorphic haeba feela ha litlhaku tse khoeleng ea pele li ka nkeloa sebaka ke sebapali sefe kapa sefe (ho kenyelletsa le sona).

Bala haholoanyane

Potso ea 109. Botebo bo phahameng ba Nesting ea Parentheses Leetcode Solution Polelo ea Bothata Bothateng bona, re fuoa khoele e nepahetseng ea li-parentheses (vps) e nang le linomoro, li-opereisara tse ling (mohlala, +, -, *) le li-parentheses tse ling (mohlala, '(', ')'). Likhoele tsa li-parentheses tse sebetsang (vps) ke: "" "d" moo d e leng nomoro efe kapa efe "(A)" haeba A e le khoele e nepahetseng ea masakaneng "A * B" haeba * ke mosebelisi leha e le ofe le A ...

Bala haholoanyane

Potso ea 110. Na Tharollo ea Leetcode ea Kamorao Polelo ea Bothata Bothateng bona, re fuoa likhoele tse peli tse fapaneng. Morero ke ho fumana hore na khoele ea pele ke tatellano ea ea bobeli. Mehlala khoele ea pele = "abc" khoele ea bobeli = "mnagbcd" nete ea pele ea khoele = "burger" ea bobeli khoele = "li-dominos" Mokhoa oa bohata (Ho pheta-pheta) Hona ho bonolo ...

Bala haholoanyane

Potso ea 111. Tharollo ea Leetcode ea Palindrome e sebetsang Polelo ea Bothata Ha re fuoa mohala, re tlameha ho tseba hore na ke palindrome, re shebile feela litlhaku tsa alphanumeric ke hore linomoro le lialfabeta feela. Hape re tlameha ho hlokomoloha linyeoe tsa litlhaku tsa alfabeta. Mohlala "Monna, leano, kanale: Panama" Tlhaloso ea 'nete: "AmanaplanacanalPanama" ke palindrome e sebetsang. "matha koloi" ...

Bala haholoanyane

Potso ea 112. Roman to Tharollo ea Leetcode e kholo Bothateng "Roman to Integer", re fuoa khoele e emelang linomoro tse ling tse nepahetseng ka sebopeho sa eona sa palo ea Seroma. Linomoro tsa Roma li emeloa ke litlhaku tse 7 tse ka fetoleloang ho li-integer ho sebelisa tafole e latelang: Tlhokomeliso: Boleng ba palo e felletseng ea palo e fanoeng ea roma e ke ke ea feta kapa ...

Bala haholoanyane

Potso ea 113. Kakaretso ea Tharollo ea Leetcode ea Roma Bothateng bona re fuoa palo e felletseng mme re kopuoa ho fetolela lipalo tsa roman. Kahoo bothata ka kakaretso bo bitsoa "Integer to Roman" mme ena ke Integer to Roman Leetcode Solution. Haeba motho a sa tsebe ka lipalo tsa Roma. Mehleng ea khale, batho ba ne ba sa ...

Bala haholoanyane

Potso ea 114. Mohala o molelele ka ho Fetisisa Ntle le ho Pheta Litlhaku Tharollo ea LeetCode Mohala o molelele ka ho Fetisisa o sa Phetang Litlhaku Tharollo ea LeetCode - Ho fanoe ka khoele, re tlameha ho fumana bolelele ba mohala o molelele ka ho fetisisa ntle le ho pheta-pheta litlhaku. Ha re shebeng mehlala e seng mekae: Mohlala pwwkew 3 Tlhaloso: Karabo ke “wke” ka bolelele ba 3 aav 2 Tlhaloso: Karabo ke “av” ka bolelele 2 Atamela-1 ...

Bala haholoanyane

Potso ea 115. Fizz Buzz Lebitso la bothata le kanna la bonahala le ferekane. Fizz Buzz ke papali eo bana ba rutoang ka eona ka karohano. Kahoo, ntle le bothata bo bongata a re hlakoleng lerata le le potileng. Polelo ea Bothata Ha re ngolle lenaneo moo bakeng sa lipalo tse 3 u hatisang "Fizz", bakeng sa lipalo tsa 5 "Buzz" ...

Bala haholoanyane

Potso ea 116. Fizz Buzz Leetcode Bothateng ba Fizz Buzz re fane ka nomoro n, hatisa mohala oa lipalo ho tloha ho 1 ho isa ho n ka maemo a fanoeng: Hatisa "Fizz" bakeng sa lipalo tse ngata tsa 3. Hatisa "Buzz" bakeng sa lipalo tse 5. Hatisa "FizzBuzz" bakeng sa lipalo ea bobeli 3 le 5. Ho seng joalo, printa nomoro ho ...

Bala haholoanyane

Potso ea 117. Tsamaisa khoele Ha re re, o fuoa khoele e kentsoeng. Thapo e kentsoe ka mofuta o itseng oa paterone, mosebetsi oa hau ke ho khetholla khoele. Ha re re, <no of times khoele e etsahala> [khoele] Mohlala Keletso 3 [b] 2 [bc] Tlhaloso ea bbbcaca Tlhaloso Mona "b" e hlaha makhetlo a 3 le "ca" e hlaha makhetlo a 2. ...

Bala haholoanyane

Potso ea 118. Tumello e latelang Bothateng bo latelang ba tumello re fane ka lentsoe, fumana lengolo le phahameng ho feta la eona. Mohlala oa ho kenya: str = "tutorialcup" tlhahiso: tlhahiso ea tutorialpcu: str = "nmhdgfecba" tlhahiso: nmheabcdfg input: str = "algorithms" tlhahiso: tlhahiso ea algorithsm: str = "spoonfeed" tlhahiso: Tumello e latelang ...

Bala haholoanyane

Potso ea 119. Lethathamo la Taba ea Lengolo Lengolong la tumello re fane ka khoele e nang le lialfabeta le linomoro feela, sebopeho se seng le se seng se khoeleng se ka fetoloa ho ba litlhaku tse nyane le litlhaku tse kholo, fumana likhoele tsohle tse fapaneng tse ka fumanoang mefuteng e fapaneng ea litlhaku tse nyane le tse kholo tsa sebapali se seng le se seng khoele. Mohlala ...

Bala haholoanyane

Potso ea 120. Nako e telele ka ho fetisisa e tloaelehileng e sebelisang ho hlophisa Ho Lumellana Prefix e Telele ka ho Fetisisa u sebelisa bothata ba ho Hlopha re fane ka letoto la likhoele, fumana sephetho se tloaelehileng se telele ka ho fetisisa. ke hore, fumana karolo ea ketapele e tloaelehileng ho likhoele tsohle. Mohlala Input1: {"tutorialcup", "tutorial", "tussle", "tumble"} Sephetho: "tu" Input2: {"thoto", "banana", "batsmen"} Sephetho: "ba" Input3: {"abcd "Khumo:" abcd "...

Bala haholoanyane

Potso ea 121. Ho Ipapisa le Kamehla Mathateng a Mathateng a Tlhaloso ea Kamehla re fane ka likhoele tse peli e le 'ngoe (a re nke hore x) e na le lialfabeta tse nyane feela ebe ea bobeli (ha re nahane hore ke y) e na le lialfabeta tse nang le litlhaku tse tlase tse nang le litlhaku tse peli tse ikhethang ke hore, "." le "*". Mosebetsi ke ho fumana hore na khoele ea bobeli ...

Bala haholoanyane

Potso ea 122. Masakaneng a Sebetsang Tharollo ea LeetCode Ho Masakaneng a Nepahetseng bothata ba LeetCode re fane ka khoele e nang le litlhaku feela '(', ')', '{', '}', '[' le ']', ho lekola hore na khoele ea ho kenya e nepahetse. Mona re tla u fa Tharollo e nepahetseng ea Masakaneng a LeetCode ho uena. Khoele e kenang e sebetsa haeba: Masakaneng a bulehileng a tlameha ho koaloa ...

Bala haholoanyane

Potso ea 123. Nako e telele ka ho fetisisa e tloaelehileng e sebelisang Trie Ho Longest Common Prefix e sebelisang bothata ba Trie re fane ka likhoele, fumana sephetho sa pele se tloaelehileng ka ho fetisisa. ke hore, fumana karolo ea pele e tloaelehileng ho likhoele tsohle. Mohlala Input1: {"tutorialcup", "tutorial", "tussle", "tumble"} Sephetho: "tu" Input2: {"thoto", "banana", "batsmen"} Sephetho: "ba" Input3: {"abcd "Khumo:" abcd "...

Bala haholoanyane

Potso ea 124. Bala 'me U re Bala 'me u bue moo re faneng ka nomoro ea N' me re hloka ho fumana kotara ea Nth ea palo ebe re re tatellano. Pele, re hloka ho utloisisa se baloang le tatellano. Pele, bona mantsoe a mang a tatellano: poleloana ea 1 ke "1". Polelo ea 2 ke ...

Bala haholoanyane

Potso ea 125. Fumana sebapali se ikhethileng ka khoele Ho Fumana sebapali se ikhethileng bothateng ba khoele, re file khoele e nang le lialfabeta tse tlase feela (az). Re hloka ho fumana semelo sa pele se sa pheta-phetoang ho eona ebe re hatisa index. haeba ho se mofuta o joalo o teng hatisa -1. Mofuta oa Keketso Ke mola o le mong o nang le khoele. Sebopeho sa Khatiso ...

Bala haholoanyane

Potso ea 126. Kakaretso ho Roma Kakaretso ea phetoho ea Roma. Re fane ka nomoro N mme re hloka ho printa palo ea Roma ea N. Linomoro tsa Roma li emetsoe ke ts'ebeliso ea litekanyetso tsa {I, V, X, L, C, D, M}. Ha re boneng mehlala e meng ea kutloisiso e ntle. Fomate ea ho Kena Ke mohala o le mong o nang le ...

Bala haholoanyane

Potso ea 127. Likhetho Tse Ikhethileng Ha re fuoa likhoele tse peli S le P1, re tlameha ho bala palo eohle ea likhetho tse ikhethileng tsa S tse lekanang le P1. Tlhokomeliso: Ho latela khoele e fanoeng ke khoele eo re e bolokang ka ho hlakola litlhaku tse ling kapa litlhaku tse ka bang teng tsa zero ho tsoa mohalong oa pele. Re ka se fetohe ...

Bala haholoanyane

Potso ea 128. Kth Sebopeho se sa pheteng Polelo ea Bothata Ho "Kth Non-repeat Character" re fane ka khoele "s". Ngola lenaneo ho fumana kth non-repeat -character. Haeba ho na le litlhaku tse ka tlase ho k tse sa pheta-phetoang khoeleng, hatisa "-1". Fomete ea Input Mohala oa pele le o le mong feela o nang le khoele “s”. ...

Bala haholoanyane

Potso ea 129. Hatisa Litsela tsohle tse ka khonehang tsa ho roba khoele ka foromo ea bracket Polelo ea Bothata Bothateng ba "Hatisa Litsela tsohle tse ka khonehang tsa ho roba khoele ka foromo ea bracket", re fane ka khoele "s". Fumana mekhoa eohle e ka khonehang ea ho khaola khoele e fanoeng ka foromo ea bracket. Koala likhoele tsohle ka har'a masakaneng (). Fomate ea ho Kena Mohala oa pele ebile e le 'ngoe feela o nang le ...

Bala haholoanyane

Potso ea 130. Nako e telele ka ho Fetisisa e Tloaelehileng ea Lentsoe ka ho Bapisa Lentsoe Polelo ea Bothata Bothateng ba "Longest Common Prefix o sebelisa Word by Word Matching", re file N strings. Ngola lenaneo ho fumana sephetho se tloaelehileng se telele ka ho fetisisa sa likhoele tse fanoeng. Fomate ea ho kenya Mohala oa pele o nang le boleng ba palo e kholo ea N e bolelang palo ea likhoele. Melao e latelang ea N ...

Bala haholoanyane

Potso ea 131. Nako e telele ka ho fetisisa e tloaelehileng e sebelisang Sebopeho ka ho Bapisa Batho Polelo ea Bothata Bothateng ba "Longest Common Prefix using Character by Character Matching" re fane ka boleng ba palo e felletseng ea likhoele tsa N le N. Ngola lenaneo ho fumana sephetho se tloaelehileng se telele ka ho fetisisa sa likhoele tse fanoeng. Fomate ea ho Kena Mohala oa pele o nang le boleng bo boholo ba N bo bolelang palo ...

Bala haholoanyane

Potso ea 132. Telele ka ho Fetisisa e Tloaelehileng E Sebelisa Binary Search II Polelo ea Bothata Bothateng ba "Longest Common Prefix Using Binary Search II" re fane ka boleng ba palo e felletseng ea likhoele tsa N le N. Ngola lenaneo le tla hatisa selelekela se tloaelehileng se telele ka ho fetisisa sa likhoele tse fanoeng. Haeba ho se na sephetho se tloaelehileng, ngola "-1". Fomate ea ho Kena Mohala oa pele o nang le ...

Bala haholoanyane

Potso ea 133. Bolelele ba nako e telele ka ho fetisisa e sebetsang Polelo ea Bothata Ho "Bolelele ba Nako e telele ka ho fetisisa e sebetsang" re fane ka khoele e nang le masakana a qalang le a koalang feela. Ngola lenaneo le tla fumana mohala oa khale ka ho fetisisa o nepahetseng. Fomate ea ho kenya: Mohala oa pele le o le mong feela o nang le khoele s. Sebopeho sa Phatlalatso ea Pele le ...

Bala haholoanyane

Potso ea 134. Lekola hore na lenane le hokahaneng la likhoele le etsa Palindrome Polelo ea Bothata Bothateng ba "Hlahloba hore na lenane le hokahaneng la likhoele le etsa bothata ba Palindrome" re fane ka lenane le hokahaneng la ho sebetsana le data ea likhoele. Ngola lenaneo ho lekola hore na data e theha palindrom kapa che. Mohlala ba-> c-> d-> ca-> b 1 Tlhaloso: Mohlala o kaholimo rea bona hore ...

Bala haholoanyane

Lipotso tsa Sefate sa Bloomberg

Potso ea 135. Ho hlahisa lintlha tse latelang tse nepahetseng ho Tharollo e 'ngoe le e 'ngoe ea Leetcode ea Node Polelo ea Bothata The Populating Next Right Pointers ho Node e 'ngoe le e 'ngoe ea LeetCode Tharollo - "Populating Next Right Pointers ho Node e 'ngoe le e' ngoe" e bolela hore ho fanoe ka motso oa sefate se phethahetseng sa binary 'me re hloka ho hlahisa ntlha e' ngoe le e 'ngoe e latelang ea node ho ea sebakeng sa eona se latelang se nepahetseng. Haeba ha ho na se latelang ...

Bala haholoanyane

Potso ea 136. Hlakola Li-Node le Tharollo ea ho Khutlela Forest Leetcode Phatlalatso ea Bothata The Delete Nodes and Return Forest LeetCode Solution - "Tlosa Li-Nodes le Return Forest" e bolela hore ho fanoe ka motso oa sefate sa binary moo node e 'ngoe le e' ngoe e nang le boleng bo ikhethang. Re boetse re fuoa lethathamo, ho_delete, moo re hlokang ho hlakola li-node tsohle tse nang le litekanyetso tse teng ...

Bala haholoanyane

Potso ea 137. Hlaphoheloa Binary Search Tree Leetcode Tharollo Polelo ea Bothata The Recover Binary Search Tree LeetCode Tharollo - "Khutlisa Binary Search Tree" e bolela hore ho fanoe ka motso oa sefate sa lipatlisiso sa binary, moo litekanyetso tsa li-node tse peli hantle li fetotsoeng ka phoso. Re hloka ho khutlisa sefate ntle le ho fetola sebopeho sa sona. Mohlala: Kenyo: motso = [1,3,null,null,2] Output: [3,1,null,null,2] ...

Bala haholoanyane

Potso ea 138. Symmetric Tree Leetcode Tharollo Tlhaloso ea Bothata The Symmetric Tree LeetCode Tharollo - "Symmetric Tree" e bolela hore ho fanoe ka motso oa sefate sa binary 'me re lokela ho hlahloba hore na sefate sa binary se fanoeng ke seipone sa sona (symmetric ho pota setsi sa sona) kapa che? Haeba E, re hloka ho khutlisa 'nete ho seng joalo, leshano. Mohlala: ...

Bala haholoanyane

Potso ea 139. Palo ea banab'eso ba Node e fanoeng ho n-ary Tree Polelo ea Bothata Bothata "Palo ea banab'eno ba Node e fanoeng ho n-ary Tree" e re o fuoa sefate sa n-ary le node ea sepheo. Fumana palo ea banab'eno ba node e lebisitsoeng. Nka hore node e lula e le teng sefateng 'me ntlha ea pele ke ...

Bala haholoanyane

Potso ea 140. Sefate sa Binary ho Phetoho ea Lifate tsa Binary Sefateng sa binary ho na le bothata ba phetoho ea patlo ea patlo ea patlo, re file sefate sa binary ho se fetolela ho Binary Search Tree ntle le ho fetola sebopeho sa sefate. Peakanyo ea tlhahiso ea tlhahiso ea mohlala ea mohlala: 13 8 6 47 25 51 Algorithm Ha rea ​​tlameha ho fetola sebopeho sa ...

Bala haholoanyane

Potso ea 141. E hlophisitsoe ka tatellano ho ea ho Banced BST Ka tatellano e hlophisitsoeng ho ba le bothata bo leka-lekaneng ba BST, re fane ka tatellano ka tatellano, re aha Balanced Binary Search Tree ho tloha ho arotsoe. Mehlala Input arr [] = {1, 2, 3, 4, 5} Tlhahiso-pele ea tlhahiso: 3 2 1 5 4 Input arr [] = {7, 11, 13, 20, 22, ...

Bala haholoanyane

Potso ea 142. Fetola BST ho ea ho Sefate se seholo Ho fetola BST ho ba sefate se seholo ho feta se fanoeng ka Sefate sa Patlo ea Binary ngola algorithm ho e fetolela ho sefate se seholo ho feta, ke hore, fetola node ka 'ngoe hore e be le kakaretso ea likarolo tsohle tse kholo ho feta eona. Tlhahiso-pele ea tlhahiso ea mohlala: 69 81 87 34 54 ...

Bala haholoanyane

Potso ea 143. BST ho Sefate se nang le Linotlolo tsohle tse Nyane Bothateng bona re fane ka Sefate sa ho Batla sa Binary, ngola algorithm ho fetolela hantle sefateng ka kakaretso ea linotlolo tsohle tse nyane. Mohlala oa tlhahiso ea tlhahiso ea mohlala: 19 7 1 54 34 88 Mokhoa o se nang tsebo o haola li-node tsohle ka bonngoe ka mokhoa o fe kapa o fe o fetang, le ...

Bala haholoanyane

Potso ea 144. Fumana node ka boleng bo tlase ho Binary Search Tree Ha u fuoa Sefate sa Patlo ea Binary, ngola algorithm ho fumana node ka boleng bo tlase sefateng sa patlo ea binary. Mokgwa wa ho kenya Input Output 5 Naive Approach At mokhoa e bonolo ke ho etsa ho parola sefate ebe o fumana node e nang le boleng bo tlase hara li-node tsohle. Sena ...

Bala haholoanyane

Potso ea 145. Theha Sefate sa Binary ho Tsoa ho Inorder Inorder le Preorder Traversals Bothateng bona, re hlophisitse le ho hlophisa pele ho sefate sa binary. Re hloka ho aha sefate sa binary ho tsoa litselaneng tse fanoeng tsa Inorder le Preorder. Ho Kena ha Mohlala: Inorder = [D, B, E, A, F, C] Preorder = [A, B, D, E, C, F] Sephetho: Pele ho tšela sefate se entsoeng ke ...

Bala haholoanyane

Potso ea 146. Khutlisa Tsela ho BST u sebelisa Mola Ho khutlisa tsela ho BST re sebelisa bothata ba lethathamo leo re le fileng Binary Search Tree le node, ngola algorithm ho khutlisa tsela ho tloha motso ho ea ho node e fanoeng. Nka hore node e teng ho BST. Node ea Input Target Node = 12 Khumo ea ho kena ka tatellano pele ho ...

Bala haholoanyane

Potso ea 147. Taelo ea boemo e tsamaeang ka foromo ea moea Bothateng bona re file sefate sa binary, hatisa boemo ba sona ba ho otlolla ka sebopeho sa moea. Mehlala Khumo Keketso 10 30 20 40 50 80 70 60 Mokhoa o se nang thuso bakeng sa tatellano ea maemo o fapakaneng ka foromo ea moea Sepheo ke ho etsa tatellano e tloaelehileng ea taolo o sebelisa ...

Bala haholoanyane

Potso ea 148. Kth Element e Nyane ho BST Bothateng bona, re fane ka BST le nomoro k, re fumane karolo ea kth e nyane ho BST. Mehlala Sefate sa Keletso [] = {5, 3, 6, 2, 4, null, null, 1} k = 3 Output 3 Sefate sa ho kenya [] = {3, 1, 4, null, 2} k = 1 Output 1. ..

Bala haholoanyane

Potso ea 149. E leka-lekaneng Binary Tree Bothateng bo leka-lekaneng ba sefate sa binary, re file motso oa sefate sa binary. Re tlameha ho tseba hore na ke bophahamo ba bolelele kapa che. Mehlala Kengo Khumo Keketso ea 'Nete Keletso: bohata Balanced Binary Tree Node e ngoe le e ngoe sefateng se leka-lekaneng sa binary e na le phapang ea 1 kapa ka tlase ...

Bala haholoanyane

Potso ea 150. Baholo-holo ba Tloaelehileng ka ho Fetisisa Fuoa motso oa sefate sa binary le li-node tse peli n1 le n2, fumana LCA (Lowest Common Ancestor) ea li-node. Mohlala Ke eng baholo-holo ba tloaelehileng (LCA)? Baholo-holo ba node n ke linomoro tse teng tseleng e lipakeng tsa motso le node. Nahana ka sefate sa binary se bontšitsoeng ho ...

Bala haholoanyane

Potso ea 151. Binary Tree odara ka mokhoa oa zigzag Ho tsamaea Fuoa sefate sa binary, hatisa tsela ea zigzag ea tatellano ea litekanyetso tsa eona tsa node. (ke hore, ho tloha ka letsohong le letšehali ho ea ho le letona, ho tloha ho le letona ho ea ho le letšehali bakeng sa boemo bo latelang ebe o chencha pakeng tsa) Mohlala nahana ka sefate sa binary se fanoeng ka tlase ka tlase ke ho putlama ha maemo a zigzag ho mefuta e kaholimo ea sefate sa binary ...

Bala haholoanyane

Potso ea 152. Ho hlahisa lintlha tse latelang ka ho le letona Node ka 'ngoe Ha u fuoa Sefate sa Binary, hokela li-node tse maemong a ts'oanang ho tloha ho le letšehali ho ea ho le letona. Sebopeho sa Node ea Sefate: Node ea sefate e na le likarolo tse 4 e leng data (palo e kholo), litsupa (tse latelang, ho le letšehali le ka ho le letona) tsa mofuta oa node ea sefate. sesupi se latelang sa ntlha ea node e lebileng ho eona ...

Bala haholoanyane

Potso ea 153. Nako e telele ka ho fetisisa e tloaelehileng e sebelisang Trie Ho Longest Common Prefix e sebelisang bothata ba Trie re fane ka likhoele, fumana sephetho sa pele se tloaelehileng ka ho fetisisa. ke hore, fumana karolo ea pele e tloaelehileng ho likhoele tsohle. Mohlala Input1: {"tutorialcup", "tutorial", "tussle", "tumble"} Sephetho: "tu" Input2: {"thoto", "banana", "batsmen"} Sephetho: "ba" Input3: {"abcd "Khumo:" abcd "...

Bala haholoanyane

Potso ea 154. Netefatsa Sefate sa Patlo ea Binary Bothata ba ho netefatsa Binary Search Tree bothata boo re bo fileng motso oa sefate, re tlameha ho sheba hore na ke sefate sa lipatlisiso tsa binary kapa che. Mohlala: Phatlalatso: Tlhaloso ea 'nete: Sefate se fanoeng ke sefate sa patlo sa binary hobane likarolo tsohle tse setseng ho karoloana e ngoe le e ngoe ...

Bala haholoanyane

Potso ea 155. Tsela ea ho Tsamaea ha Binary Tree Level Order Traversal ea sefate se fanoeng sa binary e ts'oana le BFS ea sefate sa binary. Na re se re ntse re tseba hore na haele hantle BFS ke eng? Haeba ho se joalo ha ho hlokahale hore u utloe bohloko bala feela sengoloa sohle 'me u etele lingoliloeng tsa rona tse fetileng bakeng sa kutloisiso e betere. BFS ke ...

Bala haholoanyane

Potso ea 156. Ho tlosoa Sefateng sa Binary Na re se re ntse re tseba hore na haele hantle Binary Tree ke eng? Joale posong ena, re shebane le mokhoa oa ho hlakola node eo boleng ba eona bo fanoeng. Re na le bonnete ba hore boleng ba node eo re batlang ho e hlakola bo lula bo le teng pele e tlosoa ho BT. Ka Binary ...

Bala haholoanyane

Potso ea 157. Lifate tse ikhethang tsa ho Batla ka Binary Pele re tlameha ho fumana palo e felletseng ea lipalo ho theha sefate se ikhethileng sa patlo ea binary. Ka mor'a eona, re aha tsohle tse ka khonehang tsa BST. Pele, re tlameha ho tseba kaho ea BST. Sefateng sa Binary Search, li-node tse teng ka lehlakoreng le letšehali la subtt. eng kapa eng ...

Bala haholoanyane

Lipotso tsa Kerafo ea Bloomberg

Potso ea 158. Lekola Karolo Ha re lekola bothata ba karohano re fane ka li-equations, ka sebopeho, A / B = k, moo A le B e leng likhoele mme k ke palo ea nnete. Araba lipotso tse ling, haeba karabo e le sieo khutla -1. Ho kenya mohlala: li-equations: a / b = 2.0 le b / c = lipotso tsa 3.0: a / c ...

Bala haholoanyane

Potso ea 159. Sebaka sa Max Island Tlhaloso ea Bothata: Ha ho fanoa ka matrix a 2D, matrix e na le 0 feela (e emelang metsi) le 1 (e emelang mobu) joalo ka litlatsetso. Sehlekehleke se matrix se theoa ka ho hlopha lihlopha tsohle tse haufinyane tsa 1 tse hokahantsoeng ka 4 (ka mokhoa o otlolohileng le o otlolohileng). Fumana sebaka se phahameng sa sehlekehleke ka har'a matrix. Nka hore likarolo tsohle tse 'ne tsa ...

Bala haholoanyane

Potso ea 160. Cloning ea graph Graph Cloning ke eng? Kajeno re na le re bua ka graph e sa lebisoang. Re tlameha ho etsa eng? Ho khutlisa kopi e tebileng ea graph e fanoeng. Ha re shebeng sebopeho: Node ea Sehlopha: E na le boleng ba data le baahisani ba amanang le e ngoe le e ngoe ...

Bala haholoanyane

Lipotso tsa Bloomberg Stack

Potso ea 161. Tharollo ea Leetcode ea Metsi a ho Tlisa Pula Polelo ea Bothata The Trapping Rain Water LeetCode Solution - "Trapping Rain Water" e bolela hore ho fanoe ka lethathamo la libaka tse phahameng tse emelang 'mapa oa bophahamo moo bophara ba bar e' ngoe le e 'ngoe e leng 1. Re hloka ho fumana palo ea metsi a qabeletsoeng ka mor'a pula. Mohlala: Kenyo: bophahamo = [0,1,0,2,1,0,1,3,2,1,2,1] Sephetho: 6 Tlhaloso: Sheba ...

Bala haholoanyane

Potso ea 162. Masakaneng a Sebetsang Tharollo ea Leetcode Polelo ea Bothata Tharollo ea LeetCode e Sebetsang - "Masakaneng a Tšepahalang" e re o fuoa khoele e nang le litlhaku feela '(', ')', '{', '}', '[' le ']'. Re hloka ho fumana hore na khoele ea ho kenya ke khoele e nepahetseng kapa che. Khoele ho thoe ke khoele e sebetsang haeba masakaneng a bulehileng a tlameha ho koaloa ...

Bala haholoanyane

Potso ea 163. Tharollo ea Min Stack Leetcode Rala Setatemente sa Mathata `` stack '' e ts'ehetsang Push, Pop, top le ho fumana lintlha tse tlase ka nako e sa fetoheng. Sututsa (x) - Sututsa elemente x holima stack. pop () - E tlosa karolo kaholimo ho mokotla. top () - Fumana karolo e holimo. GetMin () - Khutlisa bonyane ba karolo ka har'a mokotla. ...

Bala haholoanyane

Potso ea 164. Next Greater Element Ke Leetcode Tharollo Polelo ea Bothata Bothateng bona, re fuoa manane a mabeli ao lenaneng la pele e leng subset ea lenane la bobeli. Bakeng sa ntlha ka 'ngoe ea lenane la pele, re tlameha ho fumana lintlha tse latelang tse kholo lenaneng la bobeli. Mohlala nums1 = [4,1,2], nums2 = [1,3,4,2] [-1,3, -1] Tlhaloso: bakeng sa ntlha ea pele ea lenane1 ke hore bakeng sa 4 moo ...

Bala haholoanyane

Potso ea 165. Taelo ea boemo e tsamaeang ka foromo ea moea Bothateng bona re file sefate sa binary, hatisa boemo ba sona ba ho otlolla ka sebopeho sa moea. Mehlala Khumo Keketso 10 30 20 40 50 80 70 60 Mokhoa o se nang thuso bakeng sa tatellano ea maemo o fapakaneng ka foromo ea moea Sepheo ke ho etsa tatellano e tloaelehileng ea taolo o sebelisa ...

Bala haholoanyane

Potso ea 166. Min Stack Mathateng a min stack re tlameha ho rala stack ho kenya tšebetsong mesebetsi e latelang ka nepo, sututsa (x) -> Sutumelletsa element x ho stack stack () -> E tlosa ntho kaholimo ho stack top () -> Khutlisa element ka holim'a stack getMin () -> Khutlisa bonyane ba elemente bo teng ...

Bala haholoanyane

Potso ea 167. Tharollo ea LeetCode ea Metsi a ho Tlisa Pula Bothateng ba LeetCode ea Metsi a Trapping Rain Water, re fane ka linomoro tsa N non-negative tse emelang 'mapa oa bophahamo 'me bophara ba bar e' ngoe le e 'ngoe ke 1. Re tlameha ho fumana bongata ba metsi a ka qabelloang mohahong o ka holimo. Mohlala Ha re utloisise hore ka mohlala Bakeng sa ...

Bala haholoanyane

Potso ea 168. Tsamaisa khoele Ha re re, o fuoa khoele e kentsoeng. Thapo e kentsoe ka mofuta o itseng oa paterone, mosebetsi oa hau ke ho khetholla khoele. Ha re re, <no of times khoele e etsahala> [khoele] Mohlala Keletso 3 [b] 2 [bc] Tlhaloso ea bbbcaca Tlhaloso Mona "b" e hlaha makhetlo a 3 le "ca" e hlaha makhetlo a 2. ...

Bala haholoanyane

Potso ea 169. Binary Tree odara ka mokhoa oa zigzag Ho tsamaea Fuoa sefate sa binary, hatisa tsela ea zigzag ea tatellano ea litekanyetso tsa eona tsa node. (ke hore, ho tloha ka letsohong le letšehali ho ea ho le letona, ho tloha ho le letona ho ea ho le letšehali bakeng sa boemo bo latelang ebe o chencha pakeng tsa) Mohlala nahana ka sefate sa binary se fanoeng ka tlase ka tlase ke ho putlama ha maemo a zigzag ho mefuta e kaholimo ea sefate sa binary ...

Bala haholoanyane

Potso ea 170. Element e latelang e kholo Karolo e latelang e kholo ke bothata boo re faneng ka bona ka tatellano. Sehlopha sena se nang le boleng ba N (se kanna sa ba se setle kapa se fosahetseng). Re hloka ho fumana ea pele e kholo_element ka tatellano e fanoeng ka lehlakoreng la eona le letona. Haeba ho se na e kholo_emente nka -1. Fomate ea Input Mohala oa pele o nang le ...

Bala haholoanyane

Potso ea 171. Element e kholo e latelang ka tatellano Polelo ea Bothata Ha re fuoa lethathamo, re tla fumana karolo e latelang e kholo ea ntlha ka 'ngoe ka tatellano. Haeba ho se na ntlha e latelang e kholo ea ntho eo re tla hatisa -1, ho seng joalo re tla e hatisa. Tlhokomeliso: Ntho e latelang e kholo ke ntho e kholo le ...

Bala haholoanyane

Lipotso tsa lethathamo la Bloomberg

Potso ea 172. Karolelano ea ho falla ho tsoa ho Tharollo ea Leetcode ea Data Stream Phatlalatso ea Bothata Karolelano e Tsoang ho tloha Data Stream LeetCode Tharollo - "Moving Average from Data Stream" e bolela hore ho fanoe ka palo ea li-integers le boholo ba fensetere k. Re hloka ho bala karolelano e tsamaeang ea linomoro tsohle tse fensetereng e thellang. Haeba palo ea likarolo ho ...

Bala haholoanyane

Potso ea 173. Palo ea banab'eso ba Node e fanoeng ho n-ary Tree Polelo ea Bothata Bothata "Palo ea banab'eno ba Node e fanoeng ho n-ary Tree" e re o fuoa sefate sa n-ary le node ea sepheo. Fumana palo ea banab'eno ba node e lebisitsoeng. Nka hore node e lula e le teng sefateng 'me ntlha ea pele ke ...

Bala haholoanyane

Potso ea 174. Fumana node ka boleng bo tlase ho Binary Search Tree Ha u fuoa Sefate sa Patlo ea Binary, ngola algorithm ho fumana node ka boleng bo tlase sefateng sa patlo ea binary. Mokgwa wa ho kenya Input Output 5 Naive Approach At mokhoa e bonolo ke ho etsa ho parola sefate ebe o fumana node e nang le boleng bo tlase hara li-node tsohle. Sena ...

Bala haholoanyane

Potso ea 175. Khutlisa Tsela ho BST u sebelisa Mola Ho khutlisa tsela ho BST re sebelisa bothata ba lethathamo leo re le fileng Binary Search Tree le node, ngola algorithm ho khutlisa tsela ho tloha motso ho ea ho node e fanoeng. Nka hore node e teng ho BST. Node ea Input Target Node = 12 Khumo ea ho kena ka tatellano pele ho ...

Bala haholoanyane

Potso ea 176. Binary Tree odara ka mokhoa oa zigzag Ho tsamaea Fuoa sefate sa binary, hatisa tsela ea zigzag ea tatellano ea litekanyetso tsa eona tsa node. (ke hore, ho tloha ka letsohong le letšehali ho ea ho le letona, ho tloha ho le letona ho ea ho le letšehali bakeng sa boemo bo latelang ebe o chencha pakeng tsa) Mohlala nahana ka sefate sa binary se fanoeng ka tlase ka tlase ke ho putlama ha maemo a zigzag ho mefuta e kaholimo ea sefate sa binary ...

Bala haholoanyane

Potso ea 177. Tsela ea ho Tsamaea ha Binary Tree Level Order Traversal ea sefate se fanoeng sa binary e ts'oana le BFS ea sefate sa binary. Na re se re ntse re tseba hore na haele hantle BFS ke eng? Haeba ho se joalo ha ho hlokahale hore u utloe bohloko bala feela sengoloa sohle 'me u etele lingoliloeng tsa rona tse fetileng bakeng sa kutloisiso e betere. BFS ke ...

Bala haholoanyane

Lipotso tsa Bloomberg Matrix

Potso ea 178. Litsela Tse Ikhethang II Tharollo ea Leetcode Tlhaloso ea Bothata Litsela Tse Ikhethang II Tharollo ea LeetCode - "Litsela tse Ikhethang II" li bolela hore ho fanoe ka marang-rang a mxn moo roboto e qalang ho tloha ka holimo ho le letšehali la marang-rang. Re hloka ho fumana palo eohle ea litsela tsa ho fihla sekhutlong se ka tlase se letona sa marang-rang. ...

Bala haholoanyane

Potso ea 179. Batla Tharollo ea 2D Matrix II Leetcode Polelo ea Bothata Batla Tharollo ea 2D Matrix II LeetCode - "Batla 2D Matrix II" e u kopa ho fumana algorithm e sebetsang hantle e batlang sepheo sa boleng ho mxn integer matrix matrix. Linomoro moleng o mong le o mong, hammoho le kholomo, li hlophisoa ka tatellano e nyolohang. Mohlala: Kenyo: matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24, 18,21,23,26,30],[5]], target = XNUMX Sephetho: nnete ...

Bala haholoanyane

Potso ea 180. Beha Tharollo ea Leetcode ea Matrix Zeroes Polelo ea Bothata The Set Matrix Zeroes LeetCode Solution – “Set Matrix Zeroes” e bolela hore u filoe mxn integer matrix. ho ea 0. U tlameha ho e etsa ka ...

Bala haholoanyane

Potso ea 181. Tharollo ea Lentsoe Leetcode Tharollo Polelo ea Bothata Ha u fuoa boto ea mxn le lentsoe, fumana hore na lentsoe le teng ho grid. Lentsoe lena le ka hahuoa ho tsoa ho litlhaku tsa lisele tse haufi tse latellanang, moo lisele tse "haufi" li bapileng le tse ling. Sele e tšoanang ea lengolo e kanna ea se sebelisoe makhetlo a fetang a le mong. Mohlala ...

Bala haholoanyane

Potso ea 182. Nako e nyane e hlokahalang ho bola lilamunu tsohle Polelo ea Bothata Bothata "Nako e nyane e hlokahalang ho bola lilamunu tsohle" e re o fuoe sehlopha sa 2D, sele e ngoe le e ngoe e na le e 'ngoe ea litekanyetso tse tharo tse ka bang 0, 1 kapa 2. 0 e bolela sele e se nang letho. 1 e bolela lamunu e ncha. 2 e bolela lamunu e bolileng. Haeba se bolileng ...

Bala haholoanyane

Potso ea 183. Sebaka sa Max Island Tlhaloso ea Bothata: Ha ho fanoa ka matrix a 2D, matrix e na le 0 feela (e emelang metsi) le 1 (e emelang mobu) joalo ka litlatsetso. Sehlekehleke se matrix se theoa ka ho hlopha lihlopha tsohle tse haufinyane tsa 1 tse hokahantsoeng ka 4 (ka mokhoa o otlolohileng le o otlolohileng). Fumana sebaka se phahameng sa sehlekehleke ka har'a matrix. Nka hore likarolo tsohle tse 'ne tsa ...

Bala haholoanyane

Potso ea 184. Litsela Tse Ikhethileng Ho fanoa ka gridi ea mxn 2D 'me u eme kaholimo ho sele le ka ho le letšehali ho grid. ke hore sele e fumanehang ho (1,1). Fumana palo ea litsela tse ikhethileng tse ka nkuoang ho fihlela sele e fumanehang ho (m, n) ho tloha seleng e fumanehang ho (1,1) ...

Bala haholoanyane

Bloomberg Lipotso tse ling

Potso ea 185. Range Sum Query 2D - Tharollo e sa fetoheng ea Leetcode Tlhaloso ea Bothata Range Sum Query 2D - Immutable Leetcode Tharollo - Ho fanoe ka 2D matrix matrix, sebetsana le lipotso tse ngata tsa mofuta o latelang: Bala kakaretso ea likarolo tsa matrix ka har'a khutlontsi e hlalosoang ke sekhutlo sa eona se ka holimo le letšehali (row1, col1) le ka tlaase ho le letona. sekhutlo (row2, col2). Kenya tshebetsong sehlopha sa NumMatrix: NumMatrix(int[][] matrix) E qala ntho ka nomoro ...

Bala haholoanyane

Potso ea 186. Partition Labels LeetCode Tharollo Phapang ea Bothata Labels LeetCode Tharollo - U fuoa khoele s. Re batla ho arola khoele ka likarolo tse ngata kamoo ho ka khonehang e le hore tlhaku ka 'ngoe e hlahe boholo ba karolo e le' ngoe. Hlokomela hore karohano e etsoa e le hore kamora ho kopanya likarolo tsohle ka tatellano, ...

Bala haholoanyane

Potso ea 187. Khokahano ea Tharollo ea Array LeetCode Polelo ea Bothata : Concatenation of Array LeetCode Solution - Ho fanoe ka palo e feletseng ea bolelele ba n, u batla ho etsa li-ans tsa bolelele ba 2n moo ans[i] == nums[i] le ans[i + n] == nums[ i] bakeng sa 0 <= ke <n (0-indexed). Haholo-holo, ans ke ho kopanngoa ha lipalo tse peli. Khutlisetsa sehlopha sa ans. Mohlala : Mohlala 1 Kenyeletso: nums = [1,2,1] Output: [1,2,1,1,2,1] Tlhaloso: The array ...

Bala haholoanyane

Potso ea 188. Tharollo ea LeetCode ea Nomoro ea Fibonacci Polelo ea Bothata Tharollo ea LeetCode ea Fibonacci - "Nomoro ea Fibonacci" e bolela hore Linomoro tsa Fibonacci, tse atisang ho hlalosoa F (n) li etsa tatellano, e bitsoang tatellano ea Fibonacci, e le hore palo ka 'ngoe e be kakaretso ea tse peli tse fetileng, ho tloha ho 0 le 1. Ke hore, F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n ...

Bala haholoanyane

Potso ea 189. Tharollo e sebetsang ea Tic-Tac-Toe State LeetCode Polelo ea Bothata e sebetsa Tharollo ea LeetCode ea Tic-Tac-Toe State - Re fuoa boto ea Tic-Tac-Toe joalo ka boto ea likhoele 'me re kopuoa ho khutlisa' nete haeba ho khonahala ho fihlela boemo bona ba boto nakong ea tic- papali ea tac-toe. Letlapa le na le likarolo tse 3 x 3 ...

Bala haholoanyane

Potso ea 190. Fetola Mantsoe ka Tharollo ea LeetCode ea Mohala oa III Phatlalatso ea Bothata e Fetola Mantsoe ka Tharollo ea LeetCode ea String III - Re fuoa khoele 'me re kōptjoa ho fetola tatellano ea litlhaku lentsoeng le leng le le leng ka har'a polelo ha re ntse re boloka sebaka se tšoeu le tatellano ea mantsoe a pele. Mehlala & Litlhaloso Mohlala 1: Kenyeletso: s = "Ha re nke LeetCode ...

Bala haholoanyane

Potso ea 191. Tlosa Likopi ho Tharollo ea LeetCode e Hlophisitsoeng Phatlalatso ea Bothata Tlosa Likopi ho tsoa Lethathamong le Hlophisitsoeng Tharollo ea LeetCode - Re fuoa hlooho ea lethathamo le hlophisitsoeng le kopantsoeng. Re kopuoa ho hlakola likopi tsohle tsa hore ntho e 'ngoe le e 'ngoe e hlahe hanngoe feela ebe re khutlisa lethathamo le hlophisitsoeng le hlophisitsoeng. Mehlala & Litlhaloso Mohlala 1: Kenyeletso: hlooho ...

Bala haholoanyane

Potso ea 192. Clone Kerafo LeetCode Tharollo Tlhaloso ea Bothata Clone Graph LeetCode Tharollo - Re fuoa tšupiso ea node ka har'a graph e hokahantsoeng e sa lebelloang 'me re botsoa hore re khutlisetse kopi e tebileng ea graph. Kopi e tebileng ha e le hantle ke ntho eo ho seng node e teng kopi e tebileng e lokelang ho ba le tšupiso ...

Bala haholoanyane

Potso ea 193. Bonyane Height Trees LeetCode Tharollo Phatlalatso ea Bothata Bonyane Bophahamo ba Lifate tsa LeetCode Tharollo - Re fuoa sefate sa n nodes se ngotsoeng ho tloha ho 0 ho ea ho n-1 e le 2D array "medges" moo bohale[i] = [a_i, b_i] bo bontšang hore ho na le moeli o sa lebelloang pakeng tsa noto tse pedi a_i le b_i sefateng. Re na le ...

Bala haholoanyane

Potso ea 194. Kth Element e Nyenyane ka ho Fetisisa Tharollo ea LeetCode ea Matrix Polelo ea Bothata Kth Ntho e Nyenyane ka ho Fetisisa ka Tharollo ea LeetCode ea Matrix e Hlophisitsoeng - Re fuoa matrix ea boholo n moo mela e 'ngoe le e 'ngoe e hlophisitsoeng ka tatellano e nyolohang. Re kopuoa ho khutlisetsa kth ntho e nyane ka ho fetesisa ka har'a matrix. Hlokomela hore ke kth...

Bala haholoanyane

Potso ea 195. Theha Binary Tree ho tloha ho Preorder le Postorder Traversal LeetCode Solution Setatamente sa Bothata Theha Sefate sa Binary ho tloha ho Preorder le Postorder Traversal LeetCode Solution - Ho fanoe ka lihlopha tse peli tse feletseng, taelo ea pele le ea poso moo taelo ea pele e leng mokhoa oa ho pota-pota oa sefate sa binary sa boleng bo fapaneng le poso ke tsela ea poso ea sefate se le seng, tsosolosa le ho khutlisetsa binary sefate. Haeba ho na le likarabo tse ngata, u ka khutlisa leha e le efe ea tsona. Kenyelletso: Odara esale pele...

Bala haholoanyane

Potso ea 196. Palo ea Dice Rolls With Target Sum LeetCode Solution Polelo ea Bothata Palo ea Dice Rolls With Target Sum LeetCode Solution - U na le dice 'me lefu ka leng le na le lifahleho tsa k tse baloang ho tloha ho 1 ho isa ho k. Ha ho fanoe ka linomoro tse tharo tsa n, k, le target, khutlisetsa palo ea litsela tse ka khonehang (ho tsoa ho kakaretso ea litsela) tsa ho theola letaese hore kakaretso ea linomoro tsa sefahleho e lekane le target. Hobane karabo e ka ba ...

Bala haholoanyane

Potso ea 197. Tlosa Likopi ho tsoa Lethathamong le Hlophisitsoeng II LeetCode Tharollo Phatlalatso ea Bothata Tlosa Likopi Ho tloha Lethathamong le Hlophisitsoeng II Tharollo ea LeetCode - Ho fanoe ka hlooho ea lethathamo le hlophisitsoeng le kopantsoeng, hlakola li-node tsohle tse nang le linomoro tse kopitsoang, u siee linomoro tse fapaneng feela ho tloha lethathamong la pele. Khutlisetsa lenane le hokahaneng le hlophisitsoeng hape. Kenyelletso: hlooho = [1,2,3,3,4,4,5] Sephetho: [1,2,5] Tlhaloso Monahano mona ke ho haola ...

Bala haholoanyane

Potso ea 198. Ka Beha Lipalesa LeetCode Tharollo Phatlalatso ea Bothata e ka Beha Lipalesa Tharollo ea LeetCode - U na le sebaka se selelele sa lipalesa moo ho lenngoeng libaka tse ling, 'me tse ling ha li joalo. Leha ho le joalo, lipalesa ha li khone ho lengoa libakeng tse haufi. Ho fanoe ka palo e felletseng ea bethe ea lipalesa e nang le 0 le 1's, moo 0 e bolelang hore ha e na letho 'me 1 e bolela hore ha e na letho, 'me palo e feletseng n, khutla haeba lipalesa tse ncha li ka lengoa ...

Bala haholoanyane

Potso ea 199. Sebopeho sa Pele se Ikhethang ho Tharollo ea LeetCode ea String Polelo ea Bothata Sebopeho sa Pele se Ikhethileng ka Tharollo ea LeetCode ea String - Ho fanoe ka khoele s, fumana sebopeho sa pele se sa phete-phetoang ho sona 'me u khutlisetse index ea sona. Haeba e le sieo, khutlisetsa -1. Mohlala oa Tlhahlobo ea 1: Input: s = “leetcode” Sephetho: 0 Taba ea Teko ea 2: Kenyeletso: s = “aabb” Sephetho: -1 Tlhaloso ...

Bala haholoanyane

Potso ea 200. Hlakola Binary Tree LeetCode Tharollo Polelo ea Bothata: Invert Binary Tree LeetCode Solution - Potsong ena, Ho fanoe ka motso oa sefate leha e le sefe sa binary, ho hlokahala tharollo ho khelosa sefate sa binary se bolelang hore sefate se letšehali se lokela ho fetoha sefate se nepahetseng le ka tsela e fapaneng. Tlhaloso Re ka ipotsa hore na ke tsela efe ea sefate e ka bang ...

Bala haholoanyane

Potso ea 201. Haufi le Binary Search Tree Boleng Leetcode Tharollo Polelo ea Bothata : Haufinyane Binary Search Tree Value Leetcode Tharollo - Ho fanoe ka motso oa sefate sa lipatlisiso sa binary le boleng ba sepheo, khutlisetsa boleng ho BST e haufi le sepheo. Mohlala : Mohlala 1 Kenyeletso: motso = [4,2,5,1,3], target = 3.714286 Output: 4 Mohlala 2 Keno: motso = [1], target ...

Bala haholoanyane

Potso ea 202. Tharollo ea Leetcode List Phatlalatso ea Bothata : Lethathamo la Likarolo Tharollo ea Leetcode - Ho fanoe ka sehlooho sa lenane le amanang le boleng ba x, e arole ka tsela e le hore li-node tsohle tse ka tlaase ho x li tle pele ho li-node tse kholo ho feta kapa tse lekanang le x. U lokela ho boloka tatellano ea mantlha ea li-node ho e 'ngoe le e' ngoe ea likarolo tse peli. Mohlala : Mohlala 1 Kenyeletso: hlooho = ...

Bala haholoanyane

Potso ea 203. Moralo oa Nalane ea Sebatli Tharollo ea LeetCode Tlhaloso ea Bothata Histori ea Sebatli Tharollo ea LeetCode - U na le sebatli se nang le tabo e le 'ngoe moo u qalang leqepheng la lehae' me u ka etela url e 'ngoe, khutlela ho palo ea histori ea mehato kapa u tsoele pele historing ea palo ea mehato. Kenya tshebetsong sehlopha sa BrowserHistory: BrowserHistory(leqephe la lapeng la khoele) E qala ntho ka leqephe la lehae la ...

Bala haholoanyane

Potso ea 204. 3Sum Haufinyane Tharollo ea LeetCode Polelo ea Bothata 3Sum e Haufi ka ho Fetisisa ea Tharollo ea LeetCode – Ka lebaka la palo e felletseng ea palo ea bolelele ba n le palo e felletseng ea palo, fumana linomoro tse tharo ka lipalo hoo kakaretso e leng haufi haholo le sepheo. Khutlisetsa kakaretso ea linomoro tse tharo. U ka 'na ua nahana hore tlhahiso e' ngoe le e 'ngoe e tla ba le tharollo e le' ngoe hantle. Kenyelletso: linomoro = [-1,2,1,-4], target = 1 Sephetho: ...

Bala haholoanyane

Potso ea 205. Boholo ba Liketsahalo tsa Tharollo ea Leetcode ea Substring Polelo ea Bothata : Palo e kholo ea Liketsahalo tsa Tharollo ea Leetcode ea Substring - Ho fanoe ka khoele s, khutlisetsa palo e kholo ea liketsahalo tsa substring leha e le efe tlas'a melao e latelang: Palo ea litlhaku tse ikhethang ho substring e tlameha ho ba ka tlaase ho kapa ho lekana le maxLetters. Saese e tlase e tlameha ho ba lipakeng tsa minSize le maxSize kaofela. Mohlala ...

Bala haholoanyane

Potso ea 206. N-Queens LeetCode Tharollo Bothata Polelo ea N-Queens LeetCode Tharollo - The n-queens puzzle ke bothata ba ho beha n queens holim'a nxn chessboard hore ho se ke ha e-ba le mafumahali a mabeli a hlaselang. Ho latela palo e felletseng ea n, khutlisetsa litharollo tsohle tse fapaneng ho puzzle ea n-queens. O ka khutlisa karabo ka tatellano efe kapa efe. Tharollo e 'ngoe le e' ngoe e na le tlhophiso e ikhethileng ea boto ea ...

Bala haholoanyane

Potso ea 207. Rectangle e Khōlō ka ho Fetisisa ho Histogram LeetCode Tharollo Polelo ea Bothata Rectangle e Khōlō ka ho Fetisisa ho Histogram LeetCode Tharollo – Ha ho fanoe ka palo e fapaneng ea bophahamo ba litopo tse emelang bophahamo ba bar ea histogram moo bophara ba bar e 'ngoe le e 'ngoe e leng 1, khutlisetsa sebaka sa khutlonnetsepa e kholo ka ho fetisisa ho histogram. Mohlala oa Tlhahlobo ea 1: Kenyelletso: bophahamo = [2, 1, 5, 6, 2, 3] Sephetho: 10 Tlhaloso: ...

Bala haholoanyane

Potso ea 208. Mantsoe a Tloaelehileng a Matching Kamehla Matching Matching LeetCode Tharollo Polelo ea Mathata Matching a Tloaelehileng a Matching Regular Expression Matching LeetCode Tharollo - Ho fanoe ka khoele ea ho kenya s le mohlala p, kenya ts'ebetsong mokhoa o tloaelehileng oa ho bapisa le tšehetso bakeng sa '.' le '*' moo: '.' E tsamaellana le tlhaku e le 'ngoe.​​'*' E tsamaellana le zero kapa ho feta tsa elemente e tlang pele. Ho bapisa ho lokela ho koahela khoele eohle ea ho kenya (eseng leeme). Mohlala oa 1 oa Teko: Kenyeletso: ...

Bala haholoanyane

Potso ea 209. Binary Tree Right Side View LeetCode Tharollo Polelo ea Bothata Binary Tree Right Side View LeetCode Tharollo - Ho fanoe ka motso oa sefate sa binary, ipone u eme ka lehlakoreng le letona la eona, 'me u khutlisetse litekanyetso tsa li-node tseo u ka li bonang li laetsoe ho tloha holimo ho ea tlaase. Mohlala oa Tlhahlobo ea 1: Kenyo: motso = [1, 2, 3, null, 5, null, ...

Bala haholoanyane

Potso ea 210. Zigzag Conversion LeetCode Tharollo Polelo ea Bothata Tharollo ea LeetCode ea Zigzag - Khoele "PAYPALISHIRING" e ngotsoe ka mokhoa oa zigzag holim'a palo e fanoeng ea mela e kang ena: (o ka rata ho hlahisa mokhoa ona ka mokhoa o tsitsitseng bakeng sa ho baleha hamolemo) PAHNAPLSIIGYI ...

Bala haholoanyane

Potso ea 211. Tharollo ea LeetCode ea Minesweeper Problem Statement Minesweeper LeetCode Solution – Ha re bapale papali ea merafo (Wikipedia, papali ea inthaneteng)! U fuoa boto ea matrix ea mxn char e emelang boto ea papali moo: 'M' e emelang morafo o sa senoloang, 'E' e emela sekoere se sa senoloang, 'B' e emela lisekoere tse senotsoeng tse se nang merafo e haufi (ke hore, ka holimo, ka tlase. , ho le letšehali, ho le letona, le tsohle ...

Bala haholoanyane

Potso ea 212. Fumana Median ho tsoa ho Data Stream LeetCode Solution Phatlalatso ea Bothata Fumana Median ho tswa ho Data Stream LeetCode Tharollo - Bohareng ke boleng ba bohareng ba lenane la palo e hlophisitsoeng. Haeba boholo ba lenane bo lekana, ha ho na boleng bo bohareng 'me bohareng ke moelelo oa litekanyetso tse peli tse bohareng. Mohlala, bakeng sa arr = [2,3,4], median ...

Bala haholoanyane

Potso ea 213. Litumello ho Tharollo ea Leetcode ea String Polelo ea Bothata : Permutation in String Leetcode Tharollo - Ho fanoe ka likhoele tse peli s1 le s2, khutlela 'nete haeba s2 e na le tumello ea s1, kapa e seng ea bohata. Ka mantsoe a mang, khutlela 'nete haeba e' ngoe ea litumello tsa s1 e le karoloana ea s2. Mohlala : Mohlala 1 Kenyeletso: s1 = "ab", s2 = "eidbaooo" Sephetho: 'nete Tlhaloso: s2 e na le tumello e le 'ngoe ea s1 ("ba"). ...

Bala haholoanyane

Potso ea 214. Asteroid Collision LeetCode Tharollo Problem Statement Asteroid Collision LeetCode Solution - Re fuoa sehlopha sa linaleli sa linaleli tse emelang li-asteroid ka tatellano. Bakeng sa asteroid ka 'ngoe, boleng bo feletseng bo emela boholo ba eona, 'me letšoao le emela tataiso ea eona (moelelo o nepahetseng o nepahetseng, moelelo o fosahetseng o setseng). Asteroid ka 'ngoe e tsamaea ka lebelo le tšoanang. Fumana naha...

Bala haholoanyane

Potso ea 215. Tsela e telele ka ho Fetisisa ea Keketseho ka Tharollo ea LeetCode ea Matrix Polelo ea Bothata Tsela e Eketsehileng ka ho Fetisisa ka Tharollo ea LeetCode ea Matrix - Ho fanoe ka mxn integers matrix, khutlisetsa bolelele ba tsela e telele ka ho fetisisa e ntseng e eketseha ka matrix. Ho tloha seleng e 'ngoe le e' ngoe, u ka tsamaea ka litsela tse 'nè: ho le letšehali, ho le letona, holimo, kapa tlase. O kanna oa se ke oa tsamaea ka nqa e le 'ngoe kapa oa tsamaea ka ntle ho moeli (ke hore, ho pota-pota ha ho lumelloe). Kenyelletso:...

Bala haholoanyane

Potso ea 216. Palo ea Lihlekehleke Tse Koetsoeng Tharollo ea Leetcode Polelo ea Bothata : Palo ea Lihlekehleke Tse Koetsoeng Tharollo ea Leetcode - Ho fanoe ka marang-rang a 2D a nang le 0s (naha) le 1s (metsi). Sehlekehleke ke sehlopha se hokahaneng ka 4-directionally ea li-0 mme sehlekehleke se koetsoeng ke sehlekehleke ka ho felletseng (kaofela ka ho le letšehali, holimo, ka ho le letona, ka tlase) se pota-potiloeng ke 1s. Khutlisetsa palo ea lihlekehleke tse koetsoeng. Mohlala : Mohlala 1 Kenyeletso: grid = [[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,1,1,0, 1,0,0,0,0,1,0,1],[1,1,1,1,1,1,1,0],[2]] Sephetho : XNUMX Tlhaloso: Lihlekehleke tse putsoa ...

Bala haholoanyane

Potso ea 217. Kopanya le Deserialize Binary Tree LeetCode Tharollo Problem Statement Serialize and Deserialize Binary Tree LeetCode Solution - Serialization ke ts'ebetso ea ho fetolela sebopeho sa data kapa ntho hore e be tatellano ea likotoana e le hore e ka bolokoa faeleng kapa buffer ea memori, kapa e fetisetsoe ka har'a sehokelo sa khokahano ea marang-rang se tla tsosolosoa hamorao. ka...

Bala haholoanyane

Potso ea 218. Binary Tree Maximum Path Sum LeetCode Tharollo Polelo ea Bothata Binary Tree Maximum Path Sum LeetCode Solution - Tsela e sefateng sa binary ke tatellano ea li-node moo para e 'ngoe le e 'ngoe ea li-node tse haufi ka tatellano e nang le moeli o li kopanyang. Node e ka hlaha feela ka tatellano hang. Hlokomela hore tsela ha e hloke ...

Bala haholoanyane

Potso ea 219. Roboto e Tlantsoeng ka Circle LeetCode Tharollo Polelo ea Bothata Robot e Tlanngoeng ka Circle LeetCode Tharollo - Ka sefofane se sa feleng, roboto qalong e ema ho (0, 0) 'me e shebane le leboea. Hlokomela hore: Leboya ke tsela e ntle ya axis ya y. Tsela e ka boroa ke tsela e mpe ea axis ea y. Tsela e ka bochabela ke tsela e ntle ea x-axis. Tsela ea bophirimela ke ...

Bala haholoanyane

Potso ea 220. Binary Tree Zigzag Level Order Traversal LeetCode Tharollo Polelo ea Bothata Binary Tree Zigzag Level Order Traversal LeetCode Tharollo - Ka lebaka la motso oa sefate sa binary, khutlisetsa boemo ba zigzag ho potoloha ha boleng ba li-node tsa eona. (ke hore, ho tloha ho le letšehali ho ea ho le letona, ebe ho le letona ho ea ho le letšehali bakeng sa boemo bo latelang le ho fapanyetsana pakeng tsa). Kenyelletso: motso = [3,9,20,null,null,15,7] Output: [[3],[20,9],[15,7]] Tlhaloso Re ...

Bala haholoanyane

Potso ea 221. Fumana Tharollo ea LeetCode ea Duplicate Number Phatlalatso ea Bothata Fumana Tharollo ea LeetCode ea Palo E 'meli - Ho fanoe ka palo ea palo e kholo e nang le linomoro tsa n + 1 moo palo e 'ngoe le e 'ngoe e leng ho mefuta [1, n] e kenyellelitsoeng. Ho na le palo e le 'ngoe feela e phetoang ka lipalo, khutlisetsa palo ena e phetiloeng. O tlameha ho rarolla bothata ntle le ho fetola palo ea palo mme o sebelise sebaka se eketsehileng feela. Kenyelletso: lipalo = [1,3,4,2,2] Sephetho: 2 Tlhaloso ...

Bala haholoanyane

Potso ea 222. Element e sieo ho Tharollo e Hlophisitsoeng ea LeetCode Polelo ea Bothata: Element e sieo ka har'a Array Array LeetCode Tharollo - Ho fanoe ka palo e felletseng ea palo e hlophisoang ka tatellano e nyolohang 'me likarolo tsohle tsa eona li ikhethile 'me li fanoe hape ka palo ea k, khutlisetsa kth nomoro e sieo ho tloha ho palo e ka ho le letšehali ea lenane. Mohlala: Mohlala 1 Kenyeletso: lipalo = [4,7,9,10], k = ...

Bala haholoanyane

Potso ea 223. Path Sum II Tharollo ea LeetCode Polelo ea Bothata : Path Sum II Tharollo ea LeetCode - Ho fanoe ka motso oa sefate sa binary le palo e feletseng ea targetSum, khutlisetsa litsela tsohle tsa motso ho ea makhasi moo kakaretso ea litekanyetso tsa node tseleng e lekanang le targetSum. Tsela e 'ngoe le e' ngoe e lokela ho khutlisoa e le lethathamo la litekanyetso tsa node, eseng litšupiso tsa node. Tsela ea motso ho ea lekhasi ke tsela e qalang ho tloha ...

Bala haholoanyane

Potso ea 224. Alien Dictionary LeetCode Tharollo Polelo ea Bothata Tharollo ea Alien Dictionary LeetCode - Ho na le puo e ncha esele e sebelisang alfabeta ea Senyesemane. Leha ho le joalo, taelo har'a mangolo ha e tsejoe ho uena. U fuoa lethathamo la mantsoe a likhoele a tsoang bukeng e hlalosang mantsoe a puo esele, moo likhoele tsa mantsoe li hlophisoang ho latela melao ea puo ena e ncha. ...

Bala haholoanyane

Potso ea 225. Sehlahisoa sa Array Ntle le Tharollo ea Self LeetCode Sehlahisoa sa Bothata Sehlahisoa sa Array Ntle le Tharollo ea Self LeetCode - Ho fanoe ka palo e feletseng ea palo, khutlisetsa karabo e fapaneng hoo karabo[i] e lekanang le sehlahisoa sa likarolo tsohle tsa lipalo ntle le linomoro[i]. Sehlahisoa sa sehlongoapele leha e le sefe kapa sehlongoana sa linomoro se tiisitsoe hore se tla lekana palo e feletseng ea 32-bit. U tlameha ho ngola algorithm e tsamaeang ka nako ea O(n) ntle le ho sebelisa karohano ...

Bala haholoanyane

Potso ea 226. Palindrome Permutation LeetCode Tharollo Tlhaloso ea Bothata Palindrome Permutation LeetCode Tharollo - Re fuoa khoele mme re botsoa hore na tumello ea khoele e fanoeng e ka theha palindrome. Mehlala & Litlhaloso Mohlala 1: Kenyeletso: s = "khoutu" Sephetho: bohata Tlhaloso: ha re khone ho hlophisa litlhaku tsa "code" ho theha palindrome Mohlala 2: ...

Bala haholoanyane

Potso ea 227. Likamano tsa Manane a Mabeli a Kopantsoeng Tharollo ea LeetCode Phatlalatso ea Phatlalatso ea Bothata ba Manane a Mabeli a Kopantsoeng Tharollo ea LeetCode - Re fuoa lihlooho tsa lihlooho tse peli tse hokahaneng ka matla hloohoA le hloohoB. Ho boetse ho fanoe ka hore manane a mabeli a hokahantsoeng a ka 'na a kopana ka nako e itseng. Re kopuoa ho khutlisa node eo ba kopanang ho eona kapa ba se nang letho haeba ...

Bala haholoanyane

Potso ea 228. Permutation Sequence LeetCode Tharollo Polelo ea Bothata Tatelano ea Permutation LeetCode Tharollo - Setha [1, 2, 3, ..., n] se na le kakaretso ea n! litumello tse ikhethang. Ka ho thathamisa le ho ngola litumello tsohle ka tatellano, re fumana tatellano e latelang ea n = 3: "123" "132" "213" "231" "312" "321" Ho fanoe ka n le k, khutlisetsa tatellano ea kth ea tumello. Mohlala oa Tlhahlobo ea 1: Kenyelletso: n ...

Bala haholoanyane

Potso ea 229. Batla Litlhahiso System LeetCode Tharollo Tlhaloso ea Bothata Litlhahiso tsa Litlhahiso System LeetCode Tharollo - U fuoa mefuta e mengata ea lihlahisoa tsa likhoele le thapo searchWord. Etsa mokhoa o fanang ka maikutlo a bonyane mabitso a mararo a lihlahisoa ho tsoa lihlahisoa ka mor'a hore mongolo o mong le o mong oa searchWord o thaepe. Lihlahisoa tse sisintsoeng li tlameha ho ba le sehlongoapele se tšoanang le searchWord. Haeba ho na le lihlahisoa tse fetang tse tharo tse nang le ...

Bala haholoanyane

Potso ea 230. Fetola Sets'oants'o sa LeetCode Tharollo Polelo ea Bothata Rotate Image LeetCode Solution - U fuoa nxn 2D matrix e emelang setšoantšo, potoloha setšoantšo ka likhato tse 90 (ho ea ka nako). U tlameha ho potoloha setšoantšo sebakeng, ho bolelang hore u tlameha ho fetola matrix a 2D ka kotloloho. U SE KE UA fana ka matrix e 'ngoe ea 2D ebe u potoloha. Mohlala oa 1 oa Teko: Kenyeletso: ...

Bala haholoanyane

Potso ea 231. Ho senya Aterese ea IP LeetCode Tharollo Phatlalatso ea Bothata Ho Hlakola Aterese ea IP Tharollo ea LeetCode - Ho fanoe ka aterese e nepahetseng (IPv4) IP, khutlisetsa phetolelo e senyehileng ea aterese eo ea IP. Aterese ea IP e silafetseng e nka sebaka sa nako e 'ngoe le e 'ngoe "." ka "[.]". Input: address = "1.1.1.1" Sephetho: "1[.]1[.]1[.]1" Tlhaloso Boikutlo bo bonolo haholo. 1. theha Stringbuilder str 2. loop ka khoele ea aterese ...

Bala haholoanyane

Potso ea 232. Kth Ntho e Nyane ka ho Fetisisa ka Tharollo ea Leetcode ea BST Polelo ea Bothata Kth Ntho e Nyenyane ka ho Fetisisa Tharollo ea Leetcode ea BST - Ho fanoe ka motso oa sefate sa lipatlisiso sa binary, le palo e feletseng ea k, khutlisetsa kth e nyenyane ka ho fetisisa (1-indexed) ea litekanyetso tsohle tsa li-node sefateng. Mehlala: Kenyeletso: motso = [3,1,4,null,2], k = 1 Output: 1 Input: root = [5,3,6,2,4,null,null,1], k ...

Bala haholoanyane

Potso ea 233. Fumana Makhasi a Binary Tree LeetCode Tharollo Polelo ea Bothata Fumana Makhasi a Binary Tree LeetCode Tharollo - Ho fanoe ka motso oa sefate sa binary, bokella li-node tsa sefate joalokaha eka u etsa sena: Bokella makhasi ohle a makhasi. Tlosa li-node tsohle tsa makhasi. Pheta ho fihlela sefate se se na letho. Mohlala oa 1 oa Teko: Kenyo: motso = [1, 2, 3, ...

Bala haholoanyane

Potso ea 234. Top K Mantsoe a Khafetsa LeetCode Tharollo Polelo ea Bothata Top K Mantsoe a Khafetsa Tharollo ea LeetCode - Ho fanoe ka lethathamo la mantsoe a likhoele le palo ea k, khutlisa likhoele tsa k khafetsa ka ho fetisisa. Khutlisetsa karabo e hlophisitsoeng ho ea ka lebelo ho tloha holimo ho ea tlase. Hlopha mantsoe ka makhetlo a tšoanang ho ea ka tatellano ea mantsoe a mantsoe. Mohlala oa Tlhahlobo oa 1: Kenyeletso: mantsoe = [“i”,”love”,”leetcode”,”i”,”love”,”coding”] k = 2 Sephetho: [“i”,”love”] Tlhaloso . ..

Bala haholoanyane

Potso ea 235. Ho eketsa Tharollo ea LeetCode ea Triplet Subsequence Polelo ea Bothata : Ho Eketseha ha Tharollo ea LeetCode ea Tharollo - Ho fanoe ka palo e feletseng ea palo, khutlela 'nete haeba ho na le li-indices tse tharo (i, j, k) tse kang <j <k le nums[i] < nums[j] < nums [k]. Haeba ho se na li-indices tse joalo, khutlisetsa bohata. Mohlala : Mohlala 1: Kenyeletso: lipalo = [2,1,5,0,4,6] Sephetho: Tlhaloso ea 'nete: The ...

Bala haholoanyane

Potso ea 236. Array Nesting Leetcode Tharollo Problem Statement Array Nesting Leetcode Solution – O fuwa palo e felletseng ya palo ya bolelele ba palo n moo dinomoro e leng pheteletso ya dinomoro mothating wa [0, n - 1]. O lokela ho aha sete s[k] = {NUMs[k], nums[k]], nums[Nums[k]]], ... } e ipapisitse le molao o latelang: Karolo ea pele ho s [k] e qala ka khetho ea ...

Bala haholoanyane

Potso ea 237. Kopanya Array LeetCode Tharollo e Hlophisitsoeng Polelo ea Bothata Kopanya Array Array LeetCode Tharollo - U fuoa lihlopha tse peli tse felletseng tse nums1 le nums2, tse hlophisitsoeng ka tatellano e sa theoheng, le linomoro tse peli m le n, tse emelang palo ea likarolo ho nums1 le nums2 ka ho latellana. Kopanya nums1 le nums2 ho sehlopha se le seng se hlophisitsoeng ka tatellano e sa theoheng. Sehlopha sa ho qetela se hlophiloeng ha sea lokela ho khutlisoa ke mosebetsi, empa se bolokoe ka har'a lethathamo la nums1. ...

Bala haholoanyane

Potso ea 238. Tharollo ea LeetCode ea Nako ea mahala ea Basebetsi Polelo ea Bothata Tharollo ea Nako ea Mahala ea Basebetsi LeetCode - Re fuoa lethathamo la lenane la basebetsi, le emelang nako ea ho sebetsa bakeng sa mosebeletsi e mong le e mong. Mosebeletsi e mong le e mong o na le lethathamo la Linako tse sa amaneng, 'me linako tsena li hlophisoa. Khutlisetsa lenane la linako tse lekanyelitsoeng tse emelang nako ea mahala e tloaelehileng, ea bolelele bo nepahetseng bakeng sa basebetsi bohle, le ...

Bala haholoanyane

Potso ea 239. Ho Fetola Li-Node ho Tharollo ea Leetcode ea Lethathamo le Hokahaneng Tlhaloso ea Bothata Ho Fetola Li-Node Lethathamong le Kopantsoeng Tharollo ea Leetcode - U fuoa hlooho ea lenane le amanang, le palo e feletseng k. Khutlisetsa hlooho ea lenane le amanang ka mor'a ho fetola litekanyetso tsa kth node ho tloha qalong le node ea kth ho tloha ho pheletso (lethathamo le thathamisitsoe ka 1). Mohlala: Kenyeletso: hlooho = [1,2,3,4,5], k = 2 ...

Bala haholoanyane

Potso ea 240. Hlakola Node ho Tharollo ea Leetcode ea Lethathamo le Hokahaneng Phatlalatso ea Bothata : Hlakola Node Lethathamong le Kopantsoeng Tharollo ea Leetcode - Ngola mosebetsi oa ho hlakola node lethathamong le le leng le amanang le le leng. U ke ke ua fuoa monyetla oa ho fumana hlooho ea lenane, ho fapana le moo, u tla fuoa monyetla oa ho fumana node e lokelang ho hlakoloa ka kotloloho. Ho netefalitsoe hore node e tla hlakoloa ha e ...

Bala haholoanyane

Potso ea 241. Palo ea Lihlekehleke Tse Ikhethileng Tharollo ea Leetcode Polelo ea Bothata Palo ea Lihlekehleke Tse Ikhethileng Tharollo ea LeetCode - "Palo ea Lihlekehleke Tse Ikhethileng" e bolela hore ho fanoe ka anxm binary matrix. Sehlekehleke ke sehlopha sa 1's (e emelang naha) e hokahaneng ka 4-directionally (e rapameng kapa e otlolohileng). Sehlekehleke se nkoa se tšoana le se seng haeba feela sehlekehleke se le seng ...

Bala haholoanyane

Potso ea 242. Litšebelisano tse Fosahetseng Tharollo ea LeetCode Phatlalatso ea Bothata Litšebetso tse Fosahetseng Tharollo ea LeetCode - Ts'ebetso e ka 'na ea se ke ea sebetsa haeba: chelete e feta $ 1000, kapa; haeba e etsahala ka hare ho (le ho kenyeletsa) metsotso e 60 ea khoebo e 'ngoe e nang le lebitso le tšoanang motseng o mong. U fuoa lethathamo la likhoele tsa transaction moo transaction[i] e nang le boleng bo arohaneng ba likoma tse emelang lebitso, nako (ka metsotso), palo, le toropo ...

Bala haholoanyane

Potso ea 243. Motsoako Sum IV LeetCode Tharollo Motsoako oa Setatemente sa Bothata Sum IV LeetCode Solution - Ka lebaka la palo e fapaneng ea linomoro tse felletseng le palo e felletseng ea sepheo, khutlisetsa palo ea metsoako e ka bang teng e kopanyang sepheo. Liteko tsa liteko li hlahisoa e le hore karabo e ka lekana palo ea 32-bit. Kenyelletso: lipalo = [1,2,3], target = 4 Sephetho: 7 Tlhaloso: Tse ka khonehang ...

Bala haholoanyane

Potso ea 244. String to Integer (atoi) LeetCode Tharollo Polelo ea Bothata The String to Integer (atoi) Leetcode Solution -"String to Integer (atoi)" e bolela hore Ho kenya ts'ebetsong myAtoi(string s), e fetolang khoele ho palo e saenneng ea 32-bit (e ts'oanang le ts'ebetso ea atoi ea C/C ++ ). Algorithm bakeng sa myAtoi(string s) e tjena: Bala 'me u hlokomolohe sebaka sefe kapa sefe se etellang pele se tšoeu. Sheba hore na sebapali se latelang (haeba ...

Bala haholoanyane

Potso ea 245. Khutlisa Liaterese Tsa IP Leetcode Tharollo Polelo ea Bothata Ho Khutlisa Liaterese Tsa IP Tharollo ea LeetCode - "Khutlisa Liaterese tsa IP" e bolela hore ho fanoe ka mohala o nang le linomoro feela, re hloka ho khutlisetsa liaterese tsohle tsa IP tse ka khonehang ka tatellano leha e le efe e ka etsoang ka ho kenya matheba khoeleng. Hlokomela hore ha rea ​​lumelloa ho khutla...

Bala haholoanyane

Potso ea 246. Khoele Compression LeetCode Tharollo Tlhaloso ea Bothata Tharollo ea Khoele ea Khatello ea LeetCode - Ho fanoe ka mefuta e mengata ea litlhaku, e hatelle u sebelisa algorithm e latelang: Qala ka khoele e se nang letho s. Bakeng sa sehlopha se seng le se seng sa litlhaku tse pheta-phetoang ka li-char: Haeba bolelele ba sehlopha e le 1, kopanya sebapali ho se. Ho seng joalo, eketsa sebapali se lateloang ke bolelele ba sehlopha. Khoele e hatelitsoeng ...

Bala haholoanyane

Potso ea 247. Kerafo e nepahetseng ea Sefate sa LeetCode Tharollo Polelo ea Bothata Kerafo e Tiileng ea Sefate sa LeetCode Tharollo - Ho fanoe ka mathōko a kerafo, hlahloba hore na mathōko a etsa sefate se nepahetseng. Haeba ho joalo, khutlisetsa 'nete le bohata ka tsela e 'ngoe. Mathoko a fanoe e le 2D array ea boholo n*2 Mehlala & Litlhaloso Mohlala 1: Kenyelletso: n = 5, ...

Bala haholoanyane

Potso ea 248. Web Crawler LeetCode Tharollo Setatamente sa Bothata Web Crawler LeetCode Tharollo - Ha u fuoa URL startUrl le interface HtmlParser, kenya ts'ebetso ea web crawler ho khasa lihokelo tsohle tse tlas'a lebitso la moamoheli joalo ka startUrl. Khutlisetsa li-URL tsohle tse fumanoeng ke sebatli sa hau sa Marang-rang ka tatellano efe kapa efe. Sebapali sa hau se lokela ho: Qala leqepheng lena: qalaUrl Letsetsa HtmlParser.getUrls(url) ho fumana li-URL tsohle leqepheng la tepo la ...

Bala haholoanyane

Potso ea 249. Setene Wall LeetCode Tharollo Phatlalatso ea Bothata Setene sa Lebota LeetCode Tharollo - Ho na le lerako la litene tse khutlonnetsepa ka pel'a hau le n mela ea litene. Mola oa ith o na le palo e itseng ea litene tse bolelele bo lekanang (ke hore, yuniti e le 'ngoe) empa li ka ba tsa bophara bo fapaneng. Kakaretso ea bophara ba mola o mong le o mong ke ...

Bala haholoanyane

Potso ea 250. Tharollo e ka khonehang ea Bipartition LeetCode Phatlalatso ea Bothata e ka khonehang Bipartition LeetCode Tharollo - Re batla ho arola sehlopha sa batho ba n (ba ngotsoeng ho tloha ho 1 ho ea ho n) ka lihlopha tse peli tsa boholo leha e le bofe. Motho ka mong a ka ’na a se ke a rata batho ba bang, ’me ha baa lokela ho kena sehlopheng se le seng. Ho fanoe ka nomoro ea n le lihlopha tse sa rateheng moo li sa rateheng[i] = [ai, bi] li bontša hore motho ea ngotsoeng ai o etsa ...

Bala haholoanyane

Potso ea 251. Integer Break LeetCode Tharollo Polelo ea Bothata Integer Break LeetCode Tharollo - Ho fanoe ka palo e feletseng n, e arole ka kakaretso ea k positive integers, moo k >= 2, 'me u eketse sehlahisoa sa linomoro tseo. Re hloka ho Khutlisa sehlahisoa se phahameng seo re ka se fumanang. Kenyelletso: n = 2 Sephetho: 1 Tlhaloso: 2 = 1 + 1, ...

Bala haholoanyane

Potso ea 252. Kill Process LeetCode Tharollo Problem Statement Kill Process LeetCode Solution - U na le mekhoa ea ho theha sebopeho sa sefate se metse ka metso. U fuoa mefuta e 'meli e felletseng ea pid le ppid, moo pid[i] e leng ID ea ts'ebetso ea ith le ppid[i] ke ID ea ts'ebetso ea motsoali oa ith. Ts'ebetso e 'ngoe le e' ngoe e na le ts'ebetso ea motsoali a le mong empa e ka ba le mekhoa e mengata ea bana. Ke ts'ebetso e le 'ngoe feela e nang le ppid[i] = 0, ...

Bala haholoanyane

Potso ea 253. Moralo Hit Counter LeetCode Tharollo Moralo oa Setatemente sa Bothata Hit Counter LeetCode Tharollo - Rala k'haontareng ea ho otla e balang palo ea lipina tse fumanoeng metsotsong e 5 e fetileng (ke hore, metsotsoana e 300 e fetileng). Sistimi ea hau e lokela ho amohela paramethara ea setempe sa nako (ka metsotsoana ea granularity), 'me u ka nahana hore mehala e ntse e etsoa ho sistimi ka tatellano ea liketsahalo (ke hore, setempe sa nako se eketseha ka mokhoa o le mong). ...

Bala haholoanyane

Potso ea 254. Bonyane bo Tsamaisa ho Equal Array Elements LeetCode Tharollo Polelo ea Bothata Bonyane bo Tsamaisa ho Equal Array Elements Tharollo ea LeetCode - Ho fanoe ka palo e felletseng ea palo ea boholo ba n, khutlisetsa palo e fokolang ea metsamao e hlokahalang ho etsa hore likarolo tsohle tsa sehlopha li lekane. Ka ts'ebetso e le 'ngoe, u ka eketsa n - 1 likarolo tsa sehlopha ka 1. Mohlala 1: Kenyelletso 1: lipalo = [1, 2, 3] Sephetho: ...

Bala haholoanyane

Potso ea 255. Jump Game Leetcode Tharollo Tlhaloso ea Bothata Papali ea Leetcode Tharollo - U fuoa palo e felletseng ea palo. Qalong u behiloe lethathamong la pele la sehlopha, 'me ntho e' ngoe le e 'ngoe e hlophisitsoeng e emela bolelele ba hao ba ho qhomela boemong boo. Khutlisetsa 'nete haeba u ka fihlela index ea ho qetela, kapa ho seng joalo e fosahetseng. Mohlala: Kenyeletso 1: linomoro = [2, ...

Bala haholoanyane

Potso ea 256. Kopanya Lifate tse peli tsa Binary LeetCode Tharollo Polelo ea Bothata Kopanya Lifate tse peli tsa Binary LeetCode Solution - U fuoa lifate tse peli tsa binary root1 le root2. Ak'u nahane hore ha u beha e 'ngoe ea tsona hore e koahele e 'ngoe, li-node tse ling tsa lifate tse peli li pota-potile ha tse ling li sa koahele. U hloka ho kopanya lifate tse peli ho ...

Bala haholoanyane

Potso ea 257. Sehlahisoa sa Subarray se Tlas'a Tharollo ea K LeetCode Problem Statement Sehlahiswa sa Subarray se Tlase ho Feta K LeetCode Tharollo - Ka lebaka la palo e felletseng ya palo e felletseng le palo e felletseng ya k, khutlisetsa palo ea li-subarray tse kopaneng moo sehlahisoa sa likarolo tsohle tsa sehlopha se tlase ho k. Mohlala oa Taba ea 1: Kenyeletso: inputArr = [10, 5, 2, 6] k = 100 ...

Bala haholoanyane

Potso ea 258. Latelang Greater Element III LeetCode Tharollo Polelo ea Bothata Bothata, Next Greater Element III LeetCode Solution e bolela hore o fuoa palo e kholo ea n 'me o hloka ho fumana palo e kholo e latelang o sebelisa linomoro tse teng ho n feela. Haeba ho se na palo e joalo, u lokela ho hatisa -1. Ho feta moo, e ncha ...

Bala haholoanyane

Potso ea 259. Fetola Distance LeetCode Tharollo Setatamente sa Bothata Bothata Edita Distance LeetCode Solution e re o filoe likhoele tse peli word1 le word2 mme o hloka ho fetolela lentsoe1 ho lentsoe2 ts'ebetsong e fokolang. Lits'ebetso tse ka etsoang khoeleng ke - Kenya tlhaku Hlakola tlhaku Beha sebapali Sebaka Mehlala Nyeoe ea Teko ...

Bala haholoanyane

Potso ea 260. Bonyane Chelete ea ho Tsamaisa Chips Sebakeng se Tšoanang sa LeetCode Tharollo Phatlalatso ea Bothata Chelete e Nyenyane ea ho Tsamaisa Li-Chips Sebakeng se Tšoanang sa LeetCode Tharollo - "Bonyane Chelete ea ho Tsamaisa Chips ho ea Boemong bo Tšoanang" e bolela hore u na le n chips, moo boemo ba ith chip e leng boemo[i]. U hloka ho tsamaisa li-chips tsohle sebakeng se le seng. Ka mohato o le mong, re ...

Bala haholoanyane

Potso ea 261. Fumana Likopi Tsohle ho Array LeetCode Tharollo Polelo ea Bothata Bothata, Find All Duplicates in an Array LeetCode Solution e bolela hore o fuoa mefuta e mengata ea boholo ba n e nang le likarolo tse fapaneng [1,n]. Nomoro e 'ngoe le e 'ngoe e ka hlaha hang kapa habeli 'me u hloka ho fumana likarolo tsohle tse hlahang habeli lethathamong. Mehlala...

Bala haholoanyane

Potso ea 262. Tharollo ea Leetcode ea Nomoro e le 'Ngoe Polelo ea Bothata Tharollo ea Nomoro e le 'Ngoe ea Leetcode - Re fuoa lethathamo le se nang letho la linomoro 'me re hloka ho fumana ntho e hlahang hang feela. Ho fanoe ka potso ea hore element e 'ngoe le e 'ngoe e hlaha habeli ntle le e le' ngoe. Mohlala 1: Kenyeletso: lipalo = [2,2,1] Sephetho: 1 Mohlala 2: Kenyelletso: ...

Bala haholoanyane

Potso ea 263. Palo ea Liprofinse Tharollo ea Leetcode Polelo ea Bothata Palo ea Liprofinse Leetcode Tharollo - Re fuoa boemeli ba matrix a adjacency ea graph mme re hloka ho fumana palo ea liprofinse. Mona profinse ke sehlopha sa litoropo tse hokahaneng ka kotloloho kapa ka tsela e sa tobang 'me ha ho litoropo tse ling kantle ho sehlopha. Mohlala oa 1: Kenyeletso: isConnected ...

Bala haholoanyane

Potso ea 264. 01 Matrix LeetCode Tharollo Polelo ea Bothata Bothateng bona 01 Matrix LeetCode Solution, re hloka ho fumana sebaka sa 0 e haufinyane bakeng sa sele ka 'ngoe ea matrix e fanoeng. Matrix e na le 0 le 1 feela mme sebaka sa lisele tse peli tse haufi ke 1. Mehlala Mohlala 1: Kenyelletso: mat = ...

Bala haholoanyane

Potso ea 265. Hlopha Litlhaku ho ea ka Frequency LeetCode Tharollo Phatlalatso ea Bothata Hlophisa Litlhaku Ka Frequency LeetCode Tharollo - Ho fanoe ka khoele ea S, e hlophise ka tatellano e fokotsehang ho latela makhetlo a litlhaku. Khafetsa ea tlhaku ke palo ea makhetlo a hlahang khoeleng. Khutlisetsa khoele e hlophisitsoeng. Haeba ho na le likarabo tse ngata, khutlisetsa e 'ngoe ea tsona. Mohlala oa ho Hlopha Litlhaku Ka ...

Bala haholoanyane

Potso ea 266. Tharollo e sa fokotseng ea Array LeetCode Polelo ea Bothata Ha e fokotsehe Tharollo ea Array LeetCode - ho fanoe ka lipalo tse ngata tse nang le n integers, mosebetsi oa hau ke ho hlahloba hore na e ke ke ea fokotseha ka ho fetola ntho e le 'ngoe. Re hlalosa lenane ha le fokotsehe haeba nums[index ] <= nums[index +1] e ts'oara bakeng sa index e' ngoe le e 'ngoe (0-based) e le hore (0 <= index <= n-2). ...

Bala haholoanyane

Potso ea 267. Factorial Trailing Zeroes LeetCode Tharollo Phatlalatso ea Bothata Factorial Trailing Zeroes LeetCode Tharollo - Ho fanoe ka palo e feletseng n, khutlisetsa palo ea li-zero tse latelang ka n!. Hlokomela hore n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1. Kenyelletso: n = 3 Sephetho: 0 Tlhaloso: 3! = 6, ha ho na morao ...

Bala haholoanyane

Potso ea 268. Fetola Array e Hlophisitsoeng ho Binary Search Tree LeetCode Solutions Problem Statement Convert Sorted Array to Binary Search Tree LeetCode Solutions e re ho fanoe ka palo e felletseng ea palo moo lielemente li hlophisoang ka tatellano e nyolohang, e fetole hore e be sefate sa ho batla se leka-lekaneng sa binary. Sefate sa binary se leka-lekaneng ke sefate sa binary moo botebo ba li-subtrees tse peli tsa node e 'ngoe le e' ngoe ha bo fapane ho feta ...

Bala haholoanyane

Potso ea 269. Lentsoe Ladder LeetCode Tharollo Polelo ea Bothata Lentsoe la Lere la LeetCode Tharollo - "Lere la Mantsoe" le bolela hore u fuoa khoele e qalangWord, string endWord, le wordList. Re hloka ho fumana bolelele bo bokhutšoane ba tatellano ea phetoho (haeba ho se na tsela e teng, hatisa 0) ho tloha StartWord to EndWord ho latela maemo a fanoeng: All the Intermediate Words should ...

Bala haholoanyane

Potso ea 270. Molemo ka ho Fetisisa oa Ntlha ea Kopano LeetCode Tharollo Polelo ea Bothata The Best Meeting Point LeetCode Solution e re Ho fanoe ka marang-rang a binary a boholo ba mxn moo e mong le e mong a khethang lehae la motsoalle a le mong, re batla ho khutlisetsa sebaka se fokolang sa maeto moo kakaretso ea sebaka sa maeto e leng kakaretso ea libaka tse pakeng tsa matlo. ea...

Bala haholoanyane

Potso ea 271. Molumo o molelele ka ho Fetisisa o nang le Bonyane Tharollo ea Litlhaku tse Phetang tsa K tsa LeetCode Problem Statement The problem Substring e telele ka ho fetesisa e nang le Bonyane K e Phetang Litlhaku LeetCode Solution e re ha ho fanoe ka khoele S le palo e felletseng ea k, ho khutlisa bolelele ba khoele e telele ka ho fetisisa ea S hoo maqhubu a tlhaku e 'ngoe le e 'ngoe a le kholo ho feta kapa a lekana le k. . Mohlala oa Substring e Telele ka Bonyane ...

Bala haholoanyane

Potso ea 272. Sefate se le seng sa LeetCode Tharollo Polelo ea Bothata Bothata Same Tree e re Ho fanoe ka metso ea lifate tse peli tsa binary p le q, ngola mosebetsi ho hlahloba hore na lia tšoana kapa che. Lifate tse peli tsa binary li nkoa li tšoana haeba li tšoana ka sebopeho, 'me li-node li na le boleng bo tšoanang. Mohlala: Nyeoe ea Teko ...

Bala haholoanyane

Potso ea 273. Last Stone Weight II Tharollo ea LeetCode Problem Statement Bothata Last Stone Weight II e re o fuoa lethathamo la majoe a feletseng moo majoe[i] e leng boima ba lejoe la ith. Re bapala papali ka majoe. Lekhetlong le leng le le leng, re khetha majoe leha e le afe a mabeli ebe re a pshatla hammoho. A re re majoe a na le boima ba x le y ...

Bala haholoanyane

Potso ea 274. Spiral Matrix LeetCode Tharollo Problem Statement Spiral Matrix Problem e re Ho Spiral Matrix re batla ho hatisa likarolo tsohle tsa matrix ka mokhoa oa spiral ka tsela ea clockwise. Mokhoa oa Spiral Matrix: Idea Bothata bo ka kengoa ts'ebetsong ka ho arola matrix ka loops le ho hatisa likarolo tsohle ho e 'ngoe le e 'ngoe ...

Bala haholoanyane

Potso ea 275. Tlosa Likopi ho Tharollo e Hlophisitsoeng ea Leetcode Polelo ea Bothata The Tlosa Likopi ho tsoa ho Sorted Array Leetcode Solution - e re u fuoa palo e felletseng e hlophisitsoeng ka tatellano e sa theoheng. Re hloka ho tlosa likarolo tsohle tse qotsitsoeng le ho fetola lethathamo la mantlha e le hore tatellano e lekanyelitsoeng ea likarolo tse ikhethileng e lule e tšoana, 'me re tlaleha boleng ba ...

Bala haholoanyane

Potso ea 276. E kholo ka ho fetisisa ea BST Subtree LeetCode Tharollo Polelo ea Bothata Bothata bo boholo ka ho fetisisa ba BST Subtree LeetCode Tharollo bo re ho fanoe ka motso oa sefate sa binary, fumana subtree e kholo ka ho fetisisa, eo hape e leng Binary Search Tree (BST), moo e kholo ka ho fetisisa e bolelang subtree e nang le palo e kholo ka ho fetisisa ea li-node. Tlhokomeliso: Sefate se senyenyane se tlameha ho kenyelletsa litloholo tsohle tsa sona. Ka Binary ...

Bala haholoanyane

Potso ea 277. Khalendara ea ka I LeetCode Tharollo Polelo ea Bothata Khalendara ea Ka I LeetCode Tharollo - Re hloka ho ngola lenaneo le ka sebelisoang e le Khalendara. Re ka kenya ketsahalo e ncha haeba ho kenya ketsahalo ho ke ke ha etsa hore peheletso e habeli. Ho etsa kopo habeli ho etsahala ha liketsahalo tse peli li na le mateano a litsela a se nang letho (ke hore, motsotso o itseng ke ...

Bala haholoanyane

Potso ea 278. Hlopha Array Ka Parity LeetCode Tharollo Polelo ea Bothata Ho Hlopha Array Ka Parity LeetCode Tharollo - "Hlopha Array Ka Parity" e bolela hore u fuoa palo e felletseng ea palo, tsamaisa palo e felletseng qalong ea lethathamo le lateloang ke linomoro tse sa tloaelehang. Tlhokomeliso: Khutlisetsa sehlopha sefe kapa sefe se khotsofatsang boemo bona. Mohlala: Kenyeletso: Sephetho: ...

Bala haholoanyane

Potso ea 279. Tlosa Node ea Nth Ho tloha Qetellong ea Tharollo ea Leetcode Phatlalatso ea Bothata Tlosa Node ea Nth Ho tloha Qetellong ea Lethathamo la Leetcode Tharollo - e bolela hore u fuoa hlooho ea lenane le amanang le eona 'me u hloka ho tlosa node ea nth ho tloha qetellong ea lenane lena. Kamora ho hlakola node ena, khutlisetsa hlooho ea lenane le fetotsoeng. Mohlala: Kenyelletso:...

Bala haholoanyane

Potso ea 280. Likamore tsa Kopano II Tharollo ea LeetCode Polelo ea Bothata Likamore tsa Kopano II LeetCode Tharollo - "Likamore tsa Kopano II" li bolela hore u fuoa letoto la linako tsa nako ea liboka "likhao" moo "linako[i] = [ qala[i], qetellong[i] ]", khutlisetsa bonyane palo ea likamore tsa kopano e hlokahalang. Mohlala: linako = [[0,30],[5,10],[15,20]] 2 Tlhaloso: Ho kopana ho ka etsoa ...

Bala haholoanyane

Potso ea 281. Subarray Sum E lekana le Tharollo ea K LeetCode Polelo ea Bothata The Subarray Sum Equals K LeetCode Solution – “Subarray Sum Equals K” e bolela hore o fuoa palo e felletseng ea “nomoro” le palo e felletseng 'k', e khutlisa kakaretso ea palo ea lihlopha tse tsoelang pele tseo kakaretso ea tsona e lekanang le 'k'. Mohlala: lipalo = [1, 2, 3], k=3 2 Tlhaloso: Ho na le ...

Bala haholoanyane

Potso ea 282. Tharollo e telele ka ho fetisisa ea Palindromic Substring LeetCode Polelo ea Bothata The Longest Palindromic Substring LeetCode Solution - "Longest Palindromic Substring" e re U Fuoa khoele s, khutlisetsa substring e telele ka ho fetisisa ea palindromic ka s. Tlhokomeliso: Palindrome ke lentsoe le balehang joalo ka morao le ho ea pele, mohlala, mofumahali. Mohlala: s = "babad" "bab" Tlhaloso: Tsohle ...

Bala haholoanyane

Potso ea 283. Nako e Molemohali ea ho Reka le ho Rekisa Stock LeetCode Solution Polelo ea Bothata Nako e Molemohali ea ho Reka le ho Rekisa Stock LeetCode Tharollo - "Nako e Molemo ka ho Fetisisa ea ho Reka le ho Rekisa Stock" e bolela hore U fuoa lethathamo la litheko moo litheko[i] e leng theko ea thepa e fanoeng ka letsatsi la ith. U batla ho eketsa phaello ea hau ka ho khetha ...

Bala haholoanyane

Potso ea 284. Bohareng ba Mekhatlo e Mebeli e Hlophisitsoeng Tharollo ea LeetCode Polelo ea bothata Median of Two Sorted Arrays LeetCode solution - Bothateng ba "Median of Two Sorted Arrays", re fuoa lihlopha tse peli tse hlophisitsoeng nums1 le nums2 tsa boholo ba m le n ka ho latellana, 'me re tlameha ho khutlisetsa bohareng ba lihlopha tse peli tse hlophisitsoeng. Kakaretso ea nako ea ho matha e lokela ho ba O(log (m+n)). Mohlala oa linomoro1 = [1,3], ...

Bala haholoanyane

Potso ea 285. Palo ea Lihlekehleke tsa LeetCode Tharollo Polelo ea Bothata Palo ea Lihlekehleke tsa LeetCode Tharollo – “Palo ea Lihlekehleke” e bolela hore u fuoa mxn 2D binary grid e emelang 'mapa oa '1's (naha) le '0's (metsi), o tlameha ho khutlisa palo ea lihlekehleke. Sehlekehleke se pota-potiloe ke metsi 'me se ...

Bala haholoanyane

Potso ea 286. LRU Cache LeetCode Tharollo Lipotso Rala sebopeho sa data se latelang litšitiso tsa cache e sa tsoa Sebelisoa Haufinyane (LRU). Kenya tšebetsong sehlopha sa LRUCache: LRUCache(int capacity) Qala cache ea LRU ka boholo bo nepahetseng. int get(int key) Khutlisa boleng ba senotlolo haeba senotlolo se teng, ho seng joalo khutlisetsa -1. void put(int key, int value) Ntlafatsa boleng ba senotlolo haeba senotlolo se le teng. Ho seng joalo, eketsa li-key-value pair ho ...

Bala haholoanyane

Potso ea 287. Tlosa Lihokelo tsa Leetcode Tharollo Polelo ea Bothata Bothateng bona, re fuoa lenane le hokahanngoeng le li-node tsa lona tse nang le litekanyetso tse kholo. Re hloka ho hlakola linomoro tse ling lenaneng tse nang le boleng bo lekanang le val. Bothata ha bo hloke ho rarolloa sebakeng se le seng empa re tla tšohla mokhoa o le mong o joalo. Lethathamo la Mehlala = ...

Bala haholoanyane

Potso ea 288. Tharollo ea 'Mele oa Trailing Zeroes Leetcode Polelo ea Bothata Bothateng bona re tlameha ho fumana hore na ho tla ba le zeroes tse kae tse latelang moo n! Fuoa n e le kenyelletso. Joaloka ha ho na le zero e le 'ngoe ho tse 5! 5! = 5 * 4 * 3 * 2 * 1 = 120 Mohlala n = 3 0 Tlhaloso: 3! = 6, ha ho zero zero trailing = 0 0 Tlhaloso: 0! ...

Bala haholoanyane

Potso ea 289. Tharollo ea bongata ba lintho tsa Leetcode Polelo ea Bothata Re fuoa mefuta e mengata ea linomoro. Re hloka ho khutlisa palo e phethahetseng e fetang nako ea ⌊N / 2⌋ ka bongata moo ⌊ ⌋ e leng mosebeletsi oa mokatong. Karolo ena e bitsoa karolo ea bongata. Hlokomela hore sehlopha se kenyang se lula se na le likarolo tse ngata. ...

Bala haholoanyane

Potso ea 290. Tharollo ea Leetcode ea Base 7 Bothata ba Base 7 Leetcode Solution, e re kopa ho fetolela nomoro ho base ea 7. Nomoro e fanoeng e ka ba mpe kapa e ntle ho fihlela limilione tse 10, ka mahlakore ka bobeli moleng oa nomoro. Bothata bo bonahala bo le bonolo ebile ke phetoho e bonolo ea nomoro ea decimal ho ...

Bala haholoanyane

Potso ea 291. Tharollo ea Lethathamo la Leetcode la Palindrome Bothateng ba "Palindrome Linked List", re tlameha ho lekola hore na lenane le fuoeng la bong bo le bong bo hokahaneng ke palindrome kapa che. Lethathamo la Mehlala = {1 -> 2 -> 3 -> 2 -> 1} Tlhaloso ea 'nete # 1: Lenane lena le palindrome joalo ka ha likarolo tsohle ho tloha qalong le morao li le ...

Bala haholoanyane

Potso ea 292. Potoloha Lethathamo la Leetcode Tharollo Bothata ba Rotate List Leetcode Solution bo re fa lethathamo le hokahaneng le palo e felletseng. Re bolelloa hore re fetole lenane le hokahanngoeng ka ho le letona ke libaka tsa k. Kahoo haeba re potoloha lenaneng le hokahaneng k libakeng tse ka ho le letona, mohatong o mong le o mong re nka ntho ea hoqetela ho tsoa ho ...

Bala haholoanyane

Potso ea 293. Pow (x, n) Tharollo ea Leetcode Bothata "Pow (x, n) Tharollo ea Leetcode" e re o fuoa linomoro tse peli, e 'ngoe ea tsona ke palo ea lintlha tse phaphamalang mme e' ngoe ke palo e felletseng. Kakaretso e bolela sehlahisoa mme setsi ke palo ea ntlha e phaphametseng. Re bolelloa hore re fumane boleng kamora ho lekola sebapali ka holim'a setsi. ...

Bala haholoanyane

Potso ea 294. Kopanya Manane a mabeli a hlophisitsoeng Leetcode Solutions Lethathamo le hokahaneng le batla le tšoana le lihlopha tsa thepa ea tsona. Re ka kopanya mefuta e 'meli e hlophisitsoeng ho etsa sehlopha se hlophisitsoeng ka kakaretso. Bothateng bona, re tlameha ho kopanya manane a mabeli a hokahaneng hore a khutlise lenane le lecha le nang le likarolo tsa manane ka bobeli ka mokhoa o hlophisitsoeng. Mohlala ...

Bala haholoanyane

Potso ea 295. Tharollo Leetcode Tharollo Bothata ba Permutations Tharollo ea Leetcode e fana ka tatellano e bonolo ea linomoro mme e re kopa ho khutlisa vector e felletseng kapa tatellano ea tumello eohle ea tatellano e fanoeng. Kahoo, pele o rarolla bothata. Re lokela ho tloaelana le tumello. Kahoo, tumello ha se letho haese tokisetso ...

Bala haholoanyane

Potso ea 296. Sqrt (x) Tharollo ea Leetcode Joalokaha sehlooho se bolela, re hloka ho fumana motso o sekwere oa palo. Ha re re nomoro ke x, ebe Sqrt (x) ke nomoro e joalo ka hore Sqrt (x) * Sqrt (x) = x. Haeba motso o sekwere oa nomoro e le boleng bo itseng ba decimal, joale re tlameha ho khutlisa boleng ba fatše ba ...

Bala haholoanyane

Potso ea 297. Fetolela Array Array ho Binary Search Tree Leetcode Tharollo Nahana hore re fuoe mefuta e mengata ea linomoro. Morero ke ho aha Binary Search Tree ho tsoa mofuteng ona hore sefate se lekane bolelele. Hlokomela hore ho thoe sefate se lekane bophahamo haeba phapang ea bophahamo ba li-subtrees tsa leqele le ho le letona tsa node efe kapa efe ho ...

Bala haholoanyane

Potso ea 298. Fetola li-Node ho Li-Leetcode Solutions tsa Pairs Morero oa bothata bona ke ho chencha li-node tsa lenane le hokahanngoeng ka bobeli, ke hore, ho fapanyetsana li-node tse ling tse peli tse haufi. Haeba re lumelloa ho chencha boleng ba linomoro feela, bothata bo ka ba bobebe. Kahoo, ha rea ​​lumelloa ho fetola node ...

Bala haholoanyane

Potso ea 299. Nomoro ea Palindrome Polelo ea Bothata bothata "Palindrome Number" e re o fuoa nomoro e felletseng. Lekola hore na ke palindrome kapa che. Rarolla bothata bona ntle le ho fetolela nomoro e fanoeng hore e be khoele. Mohlala 12321 Tlhaloso ea 'nete 12321 ke palo ea palindrome hobane ha re khutlisa 12321 e fana ka 12321 ...

Bala haholoanyane

Potso ea 300. Ho kh'outa ha Huffman Re na le molaetsa oo re batlang ho o fetisa. Re batla hore molaetsa o be bonyane ka bonyane molemong oa hore litšenyehelo tse bileng teng ha ho romelloa molaetsa li le tlase. Mona re sebelisa mohopolo oa Huffman Coding ho fokotsa boholo ba molaetsa. Ha re nke hore re na le ...

Bala haholoanyane

Potso ea 301. Kakaretso e lebisitsoeng "Target Sum" ke bothata bo ikhethileng bakeng sa DPHolics tsohle tseo ke nang le tsona kajeno. Ha ho na lebaka la ho tšoenyeha ke tlo tlohella babali ba ka ba bang ba ratehang. Kaofela ha rona re fetile bothateng ba khale ba KnapSack moo re lekang ho fumana palo e phahameng ea ...

Bala haholoanyane

Potso ea 302. Merge K Mananeo a Kopaneng a Kopaneng Kopanya K e hlophisitsoeng lethathamong le thathamisitsoeng bothata e tsebahala haholo ho latela pono ea lipotso. Potso ena e botsa makhetlo a mangata likhamphaning tse kholo joalo ka Google, Microsoft, Amazon, jj. Re tlameha ho li kopanya hore e be ...

Bala haholoanyane

Potso ea 303. Kopanya Mananeo a Mabeli a Hlophisitsoeng Ho kopanya manane a mabeli a hokahaneng re a file lintlha tsa lihlooho tse peli tse hokahaneng, o li kopanye joalo ka hore ho fumanoe lenane le le leng le hokahaneng le nang le linomoro tse nang le litekanyetso ka tatellano e hlophisitsoeng khutlisa sesupa-hlooho sa lenane le kopaneng. Tlhokomeliso: kopanya lenane le hokahaneng sebakeng ntle le ho sebelisa ...

Bala haholoanyane

Potso ea 304. Phallo ea Lentsoe Word Break ke bothata bo bonts'ang mohopolo o mocha ka botlalo. Bohle re utloile ka mantsoe a kopaneng. Mantsoe a entsoe ka mantsoe a fetang a mabeli. Kajeno re na le lethathamo la mantsoe mme sohle seo re tlamehang ho se etsa ke ho sheba hore na mantsoe ohle a tsoang ho bukantswe a ka ...

Bala haholoanyane

Potso ea 305. Kopanya Manane a mabeli a hlophisitsoeng Leetcode Motsoako o kopaneng oa mefuta e 'meli ke bothata bofe ho leetcode? Ena ke potso e khahlisang haholo e botsitsoeng makhetlo a mangata ho li-compnies tse kang Amazon, Oracle, Microsoft, jj. Bothateng bona (Merge Two Sorted Lists Leetcode), re file manane a mabeli a hokahaneng. Manane ka bobeli a hokahaneng a ntse a eketseha ka tatellano. Kopanya lenane ka bobeli le hokahaneng ho ...

Bala haholoanyane

Potso ea 306. Ts'ebetsong ea LRU Cache Cache e sa tsoa sebelisoa (LRU) Cache ke mofuta oa mokhoa o sebelisetsoang ho boloka lintlha joalo hore nako e hlokahalang ea ho sebelisa data ke bonyane bo ka khonehang. LRU algorithm e sebelisitsoeng ha cache e tletse. Re tlosa lintlha tse sa tsoa sebelisoa habonolo mohopolong oa polokelo ea ...

Bala haholoanyane

Potso ea 307. Kenya linomoro tse peli Ho eketsa linomoro tse peli ke bothata moo re faneng ka lethathamo le kopaneng le se nang letho le emelang palo e felletseng. Linomoro li bolokiloe ka tatellano e fapaneng mme node e ngoe le e ngoe e tlameha ho ba le palo e le 'ngoe feela. Kenya linomoro tse peli ebe u printa sephetho ka ho sebelisa lenane le hokahaneng. Mofuta oa Keketso ...

Bala haholoanyane

Potso ea 308. Ho hloa litepisi Polelo ea Bothata Bothata "Ho hloa litepisi" ho bolela hore o fuoa litepisi tse nang le litepisi. Ka nako o ka hloa setepisi se le seng kapa litepisi tse peli. Ke linomoro tse kae tsa litsela tsa ho fihla holima litepisi? Mohlala 3 3 Tlhaloso Ho na le mekhoa e meraro ea ho hloa ...

Bala haholoanyane

Potso ea 309. Iketsetse 'me u nyenyefatse Sefate sa Binary Re fane ka sefate sa binary se nang le linomoro tsa N moo node ka 'ngoe e nang le boleng bo itseng. Re hloka ho etsa serialize le des desize sefate binary. SerializeTs'ebetso ea ho boloka sefate faeleng ntle le ho senya sebopeho sa eona e bitsoa serialization. Iketsetse le ho nyenyefatsa Sefate sa Binary Ts'ebetso ...

Bala haholoanyane

Potso ea 310. Palo e kahodimodimo Length of Chain Pairs Polelo ea Bothata Botelele bo boholo ba lipara tsa liketane tseo re li fileng linomoro tse peli, fumana ketane e telele ka ho fetisisa eo (c, d) e ka latelang (a, b) haeba b <c. Ka lipara tse fanoeng ntlha ea pele e lula e le nyane ho feta ea bobeli. Kakanyo ea Mohlala [{12, 14}, ...

Bala haholoanyane

Potso ea 311. Fumana Pair ka Phapang e Fanoeng Polelo ea Bothata Lethathamong le sa fanoang le sa hlophisoang, fumana likarolo tse peli ka har'a sehlopha se fanoeng ka phapang e fanoeng n. Mohlala Input arr [] = {120, 30, 70, 20, 5, 6}, phapang (n) = 40 Output [30, 70] Tlhaloso Mona phapano ea 30 le 70 e lekana le boleng ba ...

Bala haholoanyane

Translate »