├── .gitignore ├── LICENSE ├── Media ├── Badges │ ├── Annual-Medals │ │ ├── GIF │ │ │ ├── 2021-annual-badge.gif │ │ │ ├── 2022-annual.gif │ │ │ ├── 2023-100.gif │ │ │ ├── 2023-50.gif │ │ │ ├── 2023.gif │ │ │ ├── 2024-100-new.gif │ │ │ ├── 2024-200.gif │ │ │ ├── 2024-50.gif │ │ │ └── 2024.gif │ │ └── PNG │ │ │ ├── 2022-annual.png │ │ │ ├── 2024-100-lg.png │ │ │ ├── 2024-200-lg.png │ │ │ ├── 2024-50-lg.png │ │ │ ├── 2024-lg.png │ │ │ ├── annual-badge-2021-front.png │ │ │ ├── lg100.png │ │ │ ├── lg2023.png │ │ │ └── lg50.png │ ├── Competition-Medals │ │ ├── GIF │ │ │ ├── Guardian.gif │ │ │ └── Knight.gif │ │ └── PNG │ │ │ ├── guardian.png │ │ │ └── knight.png │ ├── Daily-Medals │ │ ├── GIF │ │ │ ├── 2021-01.gif │ │ │ ├── 2021-02.gif │ │ │ ├── 2021-03.gif │ │ │ ├── 2021-04.gif │ │ │ ├── 2021-05.gif │ │ │ ├── 2021-06.gif │ │ │ ├── 2021-07.gif │ │ │ ├── 2021-08.gif │ │ │ ├── 2021-09.gif │ │ │ ├── 2021-10.gif │ │ │ ├── 2021-11.gif │ │ │ ├── 2021-12.gif │ │ │ ├── 2022-01.gif │ │ │ ├── 2022-02.gif │ │ │ ├── 2022-03.gif │ │ │ ├── 2022-04.gif │ │ │ ├── 2022-05.gif │ │ │ ├── 2022-06.gif │ │ │ ├── 2022-07.gif │ │ │ ├── 2022-08.gif │ │ │ ├── 2022-09.gif │ │ │ ├── 2022-10.gif │ │ │ ├── 2022-11.gif │ │ │ ├── 2022-12.gif │ │ │ ├── 2023-01.gif │ │ │ ├── 2023-02.gif │ │ │ ├── 2023-03.gif │ │ │ ├── 2023-04.gif │ │ │ ├── 2023-05.gif │ │ │ ├── 2023-06.gif │ │ │ ├── 2023-07.gif │ │ │ ├── 2023-08.gif │ │ │ ├── 2023-09.gif │ │ │ ├── 2023-10.gif │ │ │ ├── 2023-11.gif │ │ │ ├── 2023-12.gif │ │ │ ├── 2024-01.gif │ │ │ ├── 2024-02.gif │ │ │ ├── 2024-03.gif │ │ │ ├── 2024-04.gif │ │ │ ├── 2024-05.gif │ │ │ ├── 2024-06.gif │ │ │ ├── 2024-07.gif │ │ │ ├── 2024-08.gif │ │ │ ├── 2024-09.gif │ │ │ ├── 2024-10.gif │ │ │ ├── 2024-11.gif │ │ │ ├── 2024-12.gif │ │ │ ├── 202501.gif │ │ │ ├── 202502.gif │ │ │ ├── 202503.gif │ │ │ ├── 202504.gif │ │ │ ├── 202505.gif │ │ │ ├── 202506.gif │ │ │ ├── 202507.gif │ │ │ ├── 202508.gif │ │ │ ├── 202509.gif │ │ │ ├── 202510.gif │ │ │ ├── 202511.gif │ │ │ └── 202512.gif │ │ └── PNG │ │ │ ├── dcc-2021-1.png │ │ │ ├── dcc-2021-10.png │ │ │ ├── dcc-2021-11.png │ │ │ ├── dcc-2021-12.png │ │ │ ├── dcc-2021-2.png │ │ │ ├── dcc-2021-3.png │ │ │ ├── dcc-2021-4.png │ │ │ ├── dcc-2021-5.png │ │ │ ├── dcc-2021-6.png │ │ │ ├── dcc-2021-7.png │ │ │ ├── dcc-2021-8.png │ │ │ ├── dcc-2021-9.png │ │ │ ├── dcc-2022-1.png │ │ │ ├── dcc-2022-10.png │ │ │ ├── dcc-2022-11.png │ │ │ ├── dcc-2022-12.png │ │ │ ├── dcc-2022-2.png │ │ │ ├── dcc-2022-3.png │ │ │ ├── dcc-2022-4.png │ │ │ ├── dcc-2022-5.png │ │ │ ├── dcc-2022-6.png │ │ │ ├── dcc-2022-7.png │ │ │ ├── dcc-2022-8.png │ │ │ ├── dcc-2022-9.png │ │ │ ├── dcc-2023-1.png │ │ │ ├── dcc-2023-10.png │ │ │ ├── dcc-2023-11.png │ │ │ ├── dcc-2023-12.png │ │ │ ├── dcc-2023-2.png │ │ │ ├── dcc-2023-3.png │ │ │ ├── dcc-2023-4.png │ │ │ ├── dcc-2023-5.png │ │ │ ├── dcc-2023-6.png │ │ │ ├── dcc-2023-7.png │ │ │ ├── dcc-2023-8.png │ │ │ ├── dcc-2023-9.png │ │ │ ├── dcc-2024-1.png │ │ │ ├── dcc-2024-10.png │ │ │ ├── dcc-2024-11.png │ │ │ ├── dcc-2024-12.png │ │ │ ├── dcc-2024-2.png │ │ │ ├── dcc-2024-3.png │ │ │ ├── dcc-2024-4.png │ │ │ ├── dcc-2024-5.png │ │ │ ├── dcc-2024-6.png │ │ │ ├── dcc-2024-7.png │ │ │ ├── dcc-2024-8.png │ │ │ ├── dcc-2024-9.png │ │ │ ├── dcc-2025-1.png │ │ │ ├── dcc-2025-10.png │ │ │ ├── dcc-2025-11.png │ │ │ ├── dcc-2025-12.png │ │ │ ├── dcc-2025-2.png │ │ │ ├── dcc-2025-3.png │ │ │ ├── dcc-2025-4.png │ │ │ ├── dcc-2025-5.png │ │ │ ├── dcc-2025-6.png │ │ │ ├── dcc-2025-7.png │ │ │ ├── dcc-2025-8.png │ │ │ └── dcc-2025-9.png │ ├── Study-Plan-Medals │ │ ├── GIF │ │ │ ├── Binary_Search.gif │ │ │ ├── Dynamic_Programming-.gif │ │ │ ├── Dynamic_Programming_Grandmaster.gif │ │ │ ├── Graph_Theory.gif │ │ │ ├── Introduction_to_Pandas.gif │ │ │ ├── JS30_GIF.gif │ │ │ ├── LC-75.gif │ │ │ ├── LeetCode_75.gif │ │ │ ├── Pandas.gif │ │ │ ├── Premium_Algo_100.gif │ │ │ ├── Premium_SQL_50.gif │ │ │ ├── Programming_Skills.gif │ │ │ ├── SQLI.gif │ │ │ ├── Top_100_Liked.gif │ │ │ ├── Top_Interview_150.gif │ │ │ ├── Top_SQL_50.gif │ │ │ ├── 二分查找_会员进阶.gif │ │ │ ├── 二分查找_入门.gif │ │ │ ├── 二分查找_基础.gif │ │ │ ├── 会员.gif │ │ │ ├── 入门.gif │ │ │ ├── 图论-optimize.gif │ │ │ ├── 图论_会员进阶.gif │ │ │ ├── 编程能力_入门.gif │ │ │ └── 编程能力_基础.gif │ │ └── PNG │ │ │ ├── Algorithm_III_Badge.png │ │ │ ├── Binary_Search.png │ │ │ ├── DP_I.png │ │ │ ├── DP_II.png │ │ │ ├── DSIII.png │ │ │ ├── DS_I.png │ │ │ ├── DS_II.png │ │ │ ├── Dynamic_Programming.png │ │ │ ├── Dynamic_Programming_Grandmaster.png │ │ │ ├── Graph_Theory.png │ │ │ ├── Introduction_to_Pandas_Badge.png │ │ │ ├── LeetCode_75.png │ │ │ ├── Pandas_icon.png │ │ │ ├── Premium_Algo_100.png │ │ │ ├── Premium_SQL_50.png │ │ │ ├── Programming_Skills.png │ │ │ ├── SQLI.png │ │ │ ├── Top_100_Liked.png │ │ │ ├── Top_Interview_150.png │ │ │ ├── Top_SQL_50.png │ │ │ ├── algorithm_I.png │ │ │ ├── algorithm_II.png │ │ │ ├── 二分查找_会员进阶.png │ │ │ ├── 二分查找_入门.png │ │ │ ├── 二分查找_基础.png │ │ │ ├── 会员.png │ │ │ ├── 入门.png │ │ │ ├── 图论-会员进阶.png │ │ │ ├── 图论.png │ │ │ ├── 基础.png │ │ │ ├── 编程能力_入门.png │ │ │ ├── 编程能力_基础.png │ │ │ └── 静态图.png │ └── Submission-Days │ │ ├── GIF │ │ ├── 1k.gif │ │ ├── 2k.gif │ │ ├── 365.gif │ │ └── 500.gif │ │ └── PNG │ │ ├── 1k.png │ │ ├── 2k.png │ │ ├── 365.png │ │ └── 500.png └── Image │ └── leetcode-challenge.png ├── README-PT.md ├── README.md ├── badges ├── badges.md └── selos.md ├── get_problem.py ├── problems ├── easy.md ├── hard.md ├── medium.md ├── solutions │ ├── 0001-two-sum │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0002-add-two-numbers │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ ├── solution.py │ │ └── solution.ts │ ├── 0003-longest-substring-without-repeating-characters │ │ ├── en │ │ │ ├── description.md │ │ │ └── explication.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.ts │ ├── 0009-palindrome-number │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0013-roman-to-integer │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ ├── solution.py │ │ └── solution.ts │ ├── 0014-longest-common-prefix │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0020-valid-parentheses │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.ts │ ├── 0021-merge-two-sorted-lists │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0035-search-insert-position │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.ts │ ├── 0070-climbing-stairs │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0112-path-sum │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0141-linked-list-cycle │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0148-sort-list │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ ├── solution.py │ │ └── solution.ts │ ├── 0191-number-of-1-bits │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.ts │ ├── 0206-reverse-linked-list │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0219-contains-duplicate-ii │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0342-power-of-four │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ ├── solution.py │ │ └── solution.ts │ ├── 0345-reverse-vowels-of-a-string │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.ts │ ├── 0387-first-unique-character-in-a-string │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0509-Fibonacci-Number │ │ ├── Solution.java │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descrição.md │ │ │ └── explicação.md │ │ ├── solution.py │ │ └── solution.ts │ ├── 0557-reverse-words-in-a-string-iii │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ ├── 0645-set-mismatch │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ ├── solution.py │ │ └── solution.ts │ ├── 0876-hand-of-straights │ │ ├── en │ │ │ ├── description.md │ │ │ └── explanation.md │ │ ├── pt │ │ │ ├── descricao.md │ │ │ └── explicacao.md │ │ └── solution.py │ └── 3090-maximum-length-substring-with-two-occurrences │ │ ├── en │ │ ├── description.md │ │ └── explanation.md │ │ ├── pt │ │ ├── descricao.md │ │ └── explicacao.md │ │ └── solution.py └── summary.md └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .venv/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Caio André, Matheus Audibert, Enzo Almedia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2021-annual-badge.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2021-annual-badge.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2022-annual.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2022-annual.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2023-100.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2023-100.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2023-50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2023-50.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2023.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2023.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2024-100-new.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2024-100-new.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2024-200.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2024-200.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2024-50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2024-50.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/GIF/2024.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/GIF/2024.gif -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/2022-annual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/2022-annual.png -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/2024-100-lg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/2024-100-lg.png -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/2024-200-lg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/2024-200-lg.png -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/2024-50-lg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/2024-50-lg.png -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/2024-lg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/2024-lg.png -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/annual-badge-2021-front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/annual-badge-2021-front.png -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/lg100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/lg100.png -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/lg2023.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/lg2023.png -------------------------------------------------------------------------------- /Media/Badges/Annual-Medals/PNG/lg50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Annual-Medals/PNG/lg50.png -------------------------------------------------------------------------------- /Media/Badges/Competition-Medals/GIF/Guardian.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Competition-Medals/GIF/Guardian.gif -------------------------------------------------------------------------------- /Media/Badges/Competition-Medals/GIF/Knight.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Competition-Medals/GIF/Knight.gif -------------------------------------------------------------------------------- /Media/Badges/Competition-Medals/PNG/guardian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Competition-Medals/PNG/guardian.png -------------------------------------------------------------------------------- /Media/Badges/Competition-Medals/PNG/knight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Competition-Medals/PNG/knight.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-01.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-02.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-03.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-04.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-05.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-06.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-07.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-08.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-09.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-10.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-11.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2021-12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2021-12.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-01.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-02.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-03.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-04.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-05.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-06.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-07.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-08.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-09.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-10.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-11.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2022-12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2022-12.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-01.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-02.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-03.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-04.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-05.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-06.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-07.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-08.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-09.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-10.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-11.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2023-12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2023-12.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-01.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-02.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-03.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-04.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-05.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-06.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-07.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-08.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-09.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-10.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-11.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/2024-12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/2024-12.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202501.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202501.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202502.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202502.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202503.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202503.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202504.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202504.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202505.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202505.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202506.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202506.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202507.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202507.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202508.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202508.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202509.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202509.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202510.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202510.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202511.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202511.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/GIF/202512.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/GIF/202512.gif -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-1.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-10.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-11.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-12.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-2.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-3.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-4.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-5.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-6.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-7.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-8.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2021-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2021-9.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-1.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-10.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-11.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-12.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-2.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-3.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-4.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-5.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-6.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-7.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-8.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2022-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2022-9.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-1.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-10.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-11.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-12.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-2.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-3.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-4.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-5.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-6.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-7.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-8.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2023-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2023-9.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-1.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-10.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-11.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-12.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-2.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-3.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-4.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-5.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-6.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-7.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-8.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2024-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2024-9.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-1.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-10.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-11.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-12.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-2.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-3.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-4.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-5.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-6.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-7.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-8.png -------------------------------------------------------------------------------- /Media/Badges/Daily-Medals/PNG/dcc-2025-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Daily-Medals/PNG/dcc-2025-9.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Binary_Search.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Binary_Search.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Dynamic_Programming-.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Dynamic_Programming-.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Dynamic_Programming_Grandmaster.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Dynamic_Programming_Grandmaster.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Graph_Theory.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Graph_Theory.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Introduction_to_Pandas.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Introduction_to_Pandas.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/JS30_GIF.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/JS30_GIF.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/LC-75.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/LC-75.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/LeetCode_75.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/LeetCode_75.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Pandas.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Pandas.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Premium_Algo_100.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Premium_Algo_100.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Premium_SQL_50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Premium_SQL_50.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Programming_Skills.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Programming_Skills.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/SQLI.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/SQLI.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Top_100_Liked.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Top_100_Liked.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Top_Interview_150.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Top_Interview_150.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/Top_SQL_50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/Top_SQL_50.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/二分查找_会员进阶.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/二分查找_会员进阶.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/二分查找_入门.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/二分查找_入门.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/二分查找_基础.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/二分查找_基础.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/会员.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/会员.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/入门.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/入门.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/图论-optimize.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/图论-optimize.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/图论_会员进阶.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/图论_会员进阶.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/编程能力_入门.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/编程能力_入门.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/GIF/编程能力_基础.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/GIF/编程能力_基础.gif -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Algorithm_III_Badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Algorithm_III_Badge.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Binary_Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Binary_Search.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/DP_I.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/DP_I.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/DP_II.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/DP_II.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/DSIII.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/DSIII.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/DS_I.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/DS_I.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/DS_II.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/DS_II.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Dynamic_Programming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Dynamic_Programming.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Dynamic_Programming_Grandmaster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Dynamic_Programming_Grandmaster.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Graph_Theory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Graph_Theory.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Introduction_to_Pandas_Badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Introduction_to_Pandas_Badge.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/LeetCode_75.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/LeetCode_75.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Pandas_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Pandas_icon.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Premium_Algo_100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Premium_Algo_100.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Premium_SQL_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Premium_SQL_50.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Programming_Skills.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Programming_Skills.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/SQLI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/SQLI.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Top_100_Liked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Top_100_Liked.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Top_Interview_150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Top_Interview_150.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/Top_SQL_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/Top_SQL_50.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/algorithm_I.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/algorithm_I.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/algorithm_II.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/algorithm_II.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/二分查找_会员进阶.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/二分查找_会员进阶.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/二分查找_入门.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/二分查找_入门.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/二分查找_基础.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/二分查找_基础.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/会员.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/会员.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/入门.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/入门.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/图论-会员进阶.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/图论-会员进阶.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/图论.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/图论.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/基础.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/基础.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/编程能力_入门.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/编程能力_入门.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/编程能力_基础.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/编程能力_基础.png -------------------------------------------------------------------------------- /Media/Badges/Study-Plan-Medals/PNG/静态图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Study-Plan-Medals/PNG/静态图.png -------------------------------------------------------------------------------- /Media/Badges/Submission-Days/GIF/1k.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Submission-Days/GIF/1k.gif -------------------------------------------------------------------------------- /Media/Badges/Submission-Days/GIF/2k.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Submission-Days/GIF/2k.gif -------------------------------------------------------------------------------- /Media/Badges/Submission-Days/GIF/365.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Submission-Days/GIF/365.gif -------------------------------------------------------------------------------- /Media/Badges/Submission-Days/GIF/500.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Submission-Days/GIF/500.gif -------------------------------------------------------------------------------- /Media/Badges/Submission-Days/PNG/1k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Submission-Days/PNG/1k.png -------------------------------------------------------------------------------- /Media/Badges/Submission-Days/PNG/2k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Submission-Days/PNG/2k.png -------------------------------------------------------------------------------- /Media/Badges/Submission-Days/PNG/365.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Submission-Days/PNG/365.png -------------------------------------------------------------------------------- /Media/Badges/Submission-Days/PNG/500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Badges/Submission-Days/PNG/500.png -------------------------------------------------------------------------------- /Media/Image/leetcode-challenge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/Media/Image/leetcode-challenge.png -------------------------------------------------------------------------------- /problems/easy.md: -------------------------------------------------------------------------------- 1 | # Easy Problems Summary 2 | 3 | This summary contains all the Easy-level challenges from LeetCode that we have already solved 4 | 5 | - **1** - [Two Sum](solutions/0001-two-sum/solution.py) 6 | - **9** - [0009-polindrome-number](solutions/0009-polindrome-number/solution.py) 7 | - **13** - [Roman to Integer](solutions/0013-roman-to-integer/solution.py) 8 | - **14** - [Longest Common Prefix](solutions/0014-longest-common-prefix/solution.py) 9 | - **20** - [Valid Parentheses](solutions/0020-valid-parentheses/solution.ts) 10 | - **21** - [Merge Two Sorted Lists](solutions/0021-merge-two-sorted-lists/solution.py) 11 | - **35** - [Search Insert Position](solutions/0035-search-insert-position/solution.ts) 12 | - **70** - [Climbing Stairs](solutions/0070-climbing-stairs/solution.py) 13 | - **112** - [Path Sum](solutions/0112-path-sum/solution.py) 14 | - **141** - [Linked List Cycle](solutions/0141-linked-list-cycle/solution.py) 15 | - **191** - [Number of 1 Bits](solutions/0191-number-of-1-bits/solution.ts) 16 | - **206** - [Reverse Linked List](solutions/0206-reverse-linked-list/solution.py) 17 | - **342** - [Power of Four](solutions/0342-power-of-four/solution.ts) 18 | - **345** - [Reverse Vowels of a String](solutions/0345-reverse-vowels-of-a-string/solution.py) 19 | - **387** - [First Unique Character in a String](solutions/0387-first-unique-character-in-a-string/solution.py) 20 | - **509** - [Fibonacci Number](solutions/0509-fibonacci-number/solution.py) 21 | - **557** - [Reverse Words in a String III](solutions/0557-reverse-words-in-a-string-iii/solution.py) 22 | - **876** - [Middle of the Linked List](solutions/0876-hand-of-straights/solution.py) 23 | - **3090** - [Maximum Length Substring With Two Occurrences](solutions/3090-maximum-length-substring-with-two-occurrences/solution.py) 24 | -------------------------------------------------------------------------------- /problems/hard.md: -------------------------------------------------------------------------------- 1 | # Hard Problems Summary 2 | 3 | This summary contains all the Hard-level challenges from LeetCode that we have already solved 4 | -------------------------------------------------------------------------------- /problems/medium.md: -------------------------------------------------------------------------------- 1 | # Medium Problems Summary 2 | 3 | This summary contains all the Medium-level challenges from LeetCode that we have already solved 4 | 5 | - **2** - [Add Two Numbers](solutions/0002-add-two-numbers/solution.py) 6 | - **3** - [Longest Substring Without Repeating Characters](solutions/0003-longest-substring-without-repeating-characters/solution.ts) 7 | - **148** - [Sort List](solutions/0148-sort-list/solution.py) 8 | -------------------------------------------------------------------------------- /problems/solutions/0001-two-sum/en/description.md: -------------------------------------------------------------------------------- 1 | # 1. Two Sum (Easy) 2 | 3 | Given an array of integers `nums` and an integer `target`, return _indices of 4 | the two numbers such that they add up to `target`_. 5 | 6 | You may assume that each input would have **_exactly_ one solution**, and you 7 | may not use the _same_ element twice. 8 | 9 | You can return the answer in any order. 10 | 11 | ## Example 1: 12 | 13 | Input: nums = [2,7,11,15], target = 9 14 | Output: [0,1] 15 | Explanation: Because nums[0] + nums[1] == 9, we return [0, 1]. 16 | 17 | ## Example 2: 18 | 19 | Input: nums = [3,2,4], target = 6 20 | Output: [1,2] 21 | 22 | ## Example 3: 23 | 24 | Input: nums = [3,3], target = 6 25 | Output: [0,1] 26 | 27 | ## Constraints 28 | 29 | - `2 <= nums.length <= 104` 30 | - `-109 <= nums[i] <= 109` 31 | - `-109 <= target <= 109` 32 | - **Only one valid answer exists.** 33 | 34 | **Follow-up:** Can you come up with an algorithm that is less than `O(n2)` 35 | time complexity? 36 | -------------------------------------------------------------------------------- /problems/solutions/0001-two-sum/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 1. Two Sum - Solution Explanation 2 | 3 | ## Approach: Using Hash Table (Dictionary) 4 | 5 | The solution uses a hash table data structure to solve the problem in a single pass through the array elements. 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. We create an empty dictionary `num_to_index` that will map each number in the array to its index. 10 | 2. We iterate through the `nums` array with a loop. 11 | 3. For each current number (`num`): 12 | - We calculate the "complement" (`target - num`) which, when added to the current number, would result in the target value. 13 | - We check if this complement has been seen before (is in the dictionary). 14 | - If we find the complement, we return the indices of the two numbers. 15 | - Otherwise, we store the current number and its index in the dictionary for future lookups. 16 | 17 | ## Step-by-Step Example: 18 | 19 | Using the example: `nums = [2, 7, 11, 15]`, `target = 9` 20 | 21 | 1. Initialize `num_to_index = {}` 22 | 2. Iteration 1: 23 | - `num = 2`, `complement = 9 - 2 = 7` 24 | - `7` is not in `num_to_index` 25 | - Add `num_to_index[2] = 0` 26 | 3. Iteration 2: 27 | - `num = 7`, `complement = 9 - 7 = 2` 28 | - `2` is in `num_to_index` with value `0` 29 | - Return `[0, 1]` (indices of numbers 2 and 7) 30 | -------------------------------------------------------------------------------- /problems/solutions/0001-two-sum/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 1. Dois Números (Fácil) 2 | 3 | Dado um array de inteiros `nums` e um inteiro `target`, retorne os _índices de dois números que somados resultem em `target`_. 4 | 5 | Você pode assumir que cada entrada terá **_exatamente_ uma solução**, e você **não pode usar o mesmo elemento duas vezes**. 6 | 7 | Você pode retornar a resposta em qualquer ordem. 8 | 9 | ## Exemplo 1: 10 | 11 | Entrada: nums = [2,7,11,15], target = 9 12 | Saída: [0,1] 13 | Explicação: Como nums[0] + nums[1] == 9, retornamos [0, 1]. 14 | 15 | ## Exemplo 2: 16 | 17 | Entrada: nums = [3,2,4], target = 6 18 | Saída: [1,2] 19 | 20 | ## Exemplo 3: 21 | 22 | Entrada: nums = [3,3], target = 6 23 | Saída: [0,1] 24 | 25 | ## Restrições 26 | 27 | - `2 <= nums.length <= 10⁴` 28 | - `-10⁹ <= nums[i] <= 10⁹` 29 | - `-10⁹ <= target <= 10⁹` 30 | - **Apenas uma resposta válida existe.** 31 | 32 | **Desafio:** Você consegue criar um algoritmo com complexidade de tempo menor que `O(n²)`? 33 | -------------------------------------------------------------------------------- /problems/solutions/0001-two-sum/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 1. Two Sum - Explicação da Solução 2 | 3 | ## Abordagem: Utilizando Hash Table (Dicionário) 4 | 5 | A solução utiliza uma estrutura de dados hash table para resolver o problema em uma única passagem pelos elementos do array. 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. Criamos um dicionário vazio `num_to_index` que irá mapear cada número do array para seu índice. 10 | 2. Percorremos o array `nums` com um loop. 11 | 3. Para cada número atual (`num`): 12 | - Calculamos o "complemento" (`target - num`) que, somado ao número atual, resultaria no valor alvo. 13 | - Verificamos se esse complemento já foi visto anteriormente (está no dicionário). 14 | - Se encontrarmos o complemento, retornamos os índices dos dois números. 15 | - Caso contrário, armazenamos o número atual e seu índice no dicionário para consultas futuras. 16 | 17 | ## Exemplo Passo a Passo: 18 | 19 | Usando o exemplo: `nums = [2, 7, 11, 15]`, `target = 9` 20 | 21 | 1. Inicializamos `num_to_index = {}` 22 | 2. Iteração 1: 23 | - `num = 2`, `complemento = 9 - 2 = 7` 24 | - `7` não está em `num_to_index` 25 | - Adicionamos `num_to_index[2] = 0` 26 | 3. Iteração 2: 27 | - `num = 7`, `complemento = 9 - 7 = 2` 28 | - `2` está em `num_to_index` com valor `0` 29 | - Retornamos `[0, 1]` (índices dos números 2 e 7) 30 | -------------------------------------------------------------------------------- /problems/solutions/0001-two-sum/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def twoSum(self, nums, target): 3 | # Dictionary to store numbers we've seen and their indices 4 | num_to_index = {} 5 | 6 | # Loop through the list with index 7 | for i in range(len(nums)): 8 | num = nums[i] 9 | complement = target - num # The number needed to reach the target 10 | 11 | # If the complement is already in the dictionary, return the pair of indices 12 | if complement in num_to_index: 13 | return [num_to_index[complement], i] 14 | 15 | # Otherwise, store the current number and its index in the dictionary 16 | num_to_index[num] = i 17 | 18 | # This point is never reached because the problem guarantees one solution 19 | return [] 20 | -------------------------------------------------------------------------------- /problems/solutions/0002-add-two-numbers/en/description.md: -------------------------------------------------------------------------------- 1 | # 2. Add Two Numbers (Medium) 2 | 3 | You are given two **non-empty** linked lists representing two non-negative 4 | integers. The digits are stored in **reverse order** , and each of their nodes 5 | contains a single digit. Add the two numbers and return the sum as a linked 6 | list. 7 | 8 | You may assume the two numbers do not contain any leading zero, except the 9 | number 0 itself. 10 | 11 | ## Example 1: 12 | 13 | ![](https://assets.leetcode.com/uploads/2020/10/02/addtwonumber1.jpg) 14 | 15 | Input: l1 = [2,4,3], l2 = [5,6,4] 16 | Output: [7,0,8] 17 | Explanation: 342 + 465 = 807. 18 | 19 | ## Example 2: 20 | 21 | Input: l1 = [0], l2 = [0] 22 | Output: [0] 23 | 24 | ## Example 3: 25 | 26 | Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] 27 | Output: [8,9,9,9,0,0,0,1] 28 | 29 | ## Constraints 30 | 31 | - The number of nodes in each linked list is in the range `[1, 100]`. 32 | - `0 <= Node.val <= 9` 33 | - It is guaranteed that the list represents a number that does not have leading zeros. 34 | -------------------------------------------------------------------------------- /problems/solutions/0002-add-two-numbers/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 2. Add Two Numbers - Solution Explanation 2 | 3 | ## Approach: Linked List Addition Simulation 4 | 5 | This solution simulates the process of adding two numbers represented as linked lists, where each node contains a digit and they are ordered from least significant digit to most significant digit (reverse order). 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. We create a "dummy" node to start our result list, making it easier to return the final head. 10 | 2. We initialize variables for the total and carry. 11 | 3. We traverse both lists and continue as long as there are nodes in either list or there is a pending carry. 12 | 4. For each position: 13 | - We start with the value of the previous carry 14 | - We add the values of the current nodes (if they exist) 15 | - We calculate the new digit (remainder of division by 10) and new carry (quotient of division by 10) 16 | - We create a new node with the calculated digit and add it to the result list 17 | 18 | ## Step-by-Step Example: 19 | 20 | Using the example: `l1 = [2,4,3]` and `l2 = [5,6,4]` representing 342 and 465 respectively. 21 | 22 | 1. Initialization: 23 | 24 | - `dummy = ListNode(0)`, `res = dummy` 25 | - `total = 0`, `carry = 0` 26 | 27 | 2. Iteration 1: 28 | 29 | - `total = 0` (initial carry) 30 | - `l1.val = 2`, `total = 2`, `l1` advances 31 | - `l2.val = 5`, `total = 7`, `l2` advances 32 | - `num = 7 % 10 = 7`, `carry = 7 // 10 = 0` 33 | - We add `ListNode(7)` to the result list 34 | 35 | 3. Iteration 2: 36 | 37 | - `total = 0` (previous carry) 38 | - `l1.val = 4`, `total = 4`, `l1` advances 39 | - `l2.val = 6`, `total = 10`, `l2` advances 40 | - `num = 10 % 10 = 0`, `carry = 10 // 10 = 1` 41 | - We add `ListNode(0)` to the result list 42 | 43 | 4. Iteration 3: 44 | 45 | - `total = 1` (previous carry) 46 | - `l1.val = 3`, `total = 4`, `l1` advances (now None) 47 | - `l2.val = 4`, `total = 8`, `l2` advances (now None) 48 | - `num = 8 % 10 = 8`, `carry = 8 // 10 = 0` 49 | - We add `ListNode(8)` to the result list 50 | 51 | 5. The loop ends as both lists have been traversed and there is no carry. 52 | 53 | 6. We return `res.next` (the node after dummy), which is the head of the result list: `[7,0,8]` representing 807. 54 | -------------------------------------------------------------------------------- /problems/solutions/0002-add-two-numbers/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 2. Somar Dois Números (Médio) 2 | 3 | Você recebe duas listas ligadas **não vazias** representando dois inteiros não negativos. Os dígitos estão armazenados em **ordem reversa**, e cada um dos nós contém um único dígito. Some os dois números e retorne o resultado como uma lista ligada. 4 | 5 | Você pode assumir que os dois números não contêm zeros à esquerda, exceto o próprio número 0. 6 | 7 | ## Exemplo 1: 8 | 9 | ![](https://assets.leetcode.com/uploads/2020/10/02/addtwonumber1.jpg) 10 | 11 | Entrada: l1 = [2,4,3], l2 = [5,6,4] 12 | Saída: [7,0,8] 13 | Explicação: 342 + 465 = 807. 14 | 15 | ## Exemplo 2: 16 | 17 | Entrada: l1 = [0], l2 = [0] 18 | Saída: [0] 19 | 20 | ## Exemplo 3: 21 | 22 | Entrada: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] 23 | Saída: [8,9,9,9,0,0,0,1] 24 | 25 | ## Restrições 26 | 27 | - O número de nós em cada lista ligada está no intervalo `[1, 100]`. 28 | - `0 <= Node.val <= 9` 29 | - É garantido que a lista representa um número que não possui zeros à esquerda. 30 | -------------------------------------------------------------------------------- /problems/solutions/0002-add-two-numbers/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 2. Add Two Numbers - Explicação da Solução 2 | 3 | ## Abordagem: Simulação de Adição com Listas Encadeadas 4 | 5 | Esta solução simula o processo de adição de dois números representados como listas encadeadas, onde cada nó contém um dígito e estão ordenados do dígito menos significativo para o mais significativo (ordem inversa). 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. Criamos um nó "dummy" para iniciar nossa lista de resultados, facilitando o retorno do cabeçalho final. 10 | 2. Inicializamos variáveis para o total e para o carry (transporte). 11 | 3. Percorremos ambas as listas e continuamos enquanto houver nós em qualquer uma das listas ou um carry pendente. 12 | 4. Para cada posição: 13 | - Começamos com o valor do carry anterior 14 | - Adicionamos os valores dos nós atuais (se existirem) 15 | - Calculamos o novo dígito (resto da divisão por 10) e o novo carry (quociente da divisão por 10) 16 | - Criamos um novo nó com o dígito calculado e o adicionamos à lista de resultados 17 | 18 | ## Exemplo Passo a Passo: 19 | 20 | Usando o exemplo: `l1 = [2,4,3]` e `l2 = [5,6,4]` que representam respectivamente 342 e 465. 21 | 22 | 1. Inicialização: 23 | 24 | - `dummy = ListNode(0)`, `res = dummy` 25 | - `total = 0`, `carry = 0` 26 | 27 | 2. Iteração 1: 28 | 29 | - `total = 0` (carry inicial) 30 | - `l1.val = 2`, `total = 2`, `l1` avança 31 | - `l2.val = 5`, `total = 7`, `l2` avança 32 | - `num = 7 % 10 = 7`, `carry = 7 // 10 = 0` 33 | - Adicionamos `ListNode(7)` à lista de resultados 34 | 35 | 3. Iteração 2: 36 | 37 | - `total = 0` (carry anterior) 38 | - `l1.val = 4`, `total = 4`, `l1` avança 39 | - `l2.val = 6`, `total = 10`, `l2` avança 40 | - `num = 10 % 10 = 0`, `carry = 10 // 10 = 1` 41 | - Adicionamos `ListNode(0)` à lista de resultados 42 | 43 | 4. Iteração 3: 44 | 45 | - `total = 1` (carry anterior) 46 | - `l1.val = 3`, `total = 4`, `l1` avança (agora é None) 47 | - `l2.val = 4`, `total = 8`, `l2` avança (agora é None) 48 | - `num = 8 % 10 = 8`, `carry = 8 // 10 = 0` 49 | - Adicionamos `ListNode(8)` à lista de resultados 50 | 51 | 5. O loop termina, pois ambas as listas foram percorridas e não há carry. 52 | 53 | 6. Retornamos `res.next` (o nó após o dummy), que é a cabeça da lista resultante: `[7,0,8]` representando 807. 54 | -------------------------------------------------------------------------------- /problems/solutions/0002-add-two-numbers/solution.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | class ListNode: 4 | def __init__(self, val=0, next=None): 5 | self.val = val 6 | self.next = next 7 | 8 | class Solution: 9 | def addTwoNumbers(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]: 10 | 11 | # Create a dummy node to start the result linked list 12 | dummy = ListNode() 13 | res = dummy # This will be used to return the result 14 | 15 | total = carry = 0 # Initialize total and carry variables 16 | 17 | # Loop until both lists are fully traversed and there's no carry left 18 | while l1 or l2 or carry: 19 | total = carry # Start with carry from the previous step 20 | 21 | if l1: 22 | total += l1.val # Add l1's value if it exists 23 | l1 = l1.next # Move to the next node in l1 24 | if l2: 25 | total += l2.val # Add l2's value if it exists 26 | l2 = l2.next # Move to the next node in l2 27 | 28 | # Compute the new digit and update the carry 29 | num = total % 10 # Digit to store in the node 30 | carry = total // 10 # Carry for the next step 31 | 32 | # Create a new node with the computed digit and link it 33 | dummy.next = ListNode(num) 34 | dummy = dummy.next # Move dummy to the new node 35 | 36 | # Return the next node after the dummy, which is the actual head of the result list 37 | return res.next 38 | -------------------------------------------------------------------------------- /problems/solutions/0002-add-two-numbers/solution.ts: -------------------------------------------------------------------------------- 1 | class ListNode { 2 | val: number; 3 | next: ListNode | null; 4 | constructor(val?: number, next?: ListNode | null) { 5 | this.val = val === undefined ? 0 : val; 6 | this.next = next === undefined ? null : next; 7 | } 8 | } 9 | 10 | function addTwoNumbers( 11 | l1: ListNode | null, 12 | l2: ListNode | null 13 | ): ListNode | null { 14 | const dummy = new ListNode(); 15 | let current = dummy; 16 | let carry = 0; 17 | 18 | while (l1 || l2 || carry) { 19 | let total = carry; 20 | 21 | if (l1) { 22 | total += l1.val; 23 | l1 = l1.next; 24 | } 25 | 26 | if (l2) { 27 | total += l2.val; 28 | l2 = l2.next; 29 | } 30 | 31 | const num = total % 10; 32 | carry = Math.floor(total / 10); 33 | 34 | current.next = new ListNode(num); 35 | current = current.next; 36 | } 37 | 38 | return dummy.next; 39 | } 40 | -------------------------------------------------------------------------------- /problems/solutions/0003-longest-substring-without-repeating-characters/en/description.md: -------------------------------------------------------------------------------- 1 | ## 3. Longest Substring Without Repeating Characters (Medium) 2 | 3 | 4 | Given a string `s`, find the length of the `longest` **substring** without duplicate characters. 5 | 6 | 7 | 8 | ## Example 1: 9 | 10 | Input: s = "abcabcbb" 11 | Output: 3 12 | Explanation: The answer is "abc", with the length of 3. 13 | 14 | 15 | ## Example 2: 16 | 17 | Input: s = "bbbbb" 18 | Output: 1 19 | Explanation: The answer is "b", with the length of 1. 20 | 21 | 22 | ## Example 3: 23 | 24 | Input: s = "pwwkew" 25 | Output: 3 26 | Explanation: The answer is "wke", with the length of 3. 27 | Notice that the answer must be a substring, "pwke" is a subsequence and not a substring. 28 | 29 | 30 | ## Constraints: 31 | 32 | `0<= s.length <= 5 * 10**4` 33 | `s` consists of English letters, digits, symbols and spaces. -------------------------------------------------------------------------------- /problems/solutions/0003-longest-substring-without-repeating-characters/pt/descricao.md: -------------------------------------------------------------------------------- 1 | ## 3. Substring Mais Longa Sem Caracteres Repetidos (Médio) 2 | 3 | Dada uma string `s`, encontre o comprimento da **maior substring** (sequência contínua de caracteres) **sem caracteres repetidos**. 4 | 5 | --- 6 | 7 | ## 🔍 Exemplos 8 | 9 | ## Example 1: 10 | 11 | Entrada: s = "abcabcbb" 12 | Saida: 3 13 | Explicação: A resposta é "abc", com comprimento igual a 3. 14 | 15 | ## Example 2: 16 | 17 | Entrada: s = "bbbbb" 18 | Saída: 1 19 | Explicação: A resposta é "b", com comprimento igual a 1. 20 | 21 | ## Example 3: 22 | 23 | Entrada: s = "pwwkew" 24 | Saída: 3 25 | Explicação: A resposta é "wke", com comprimento igual a 3. 26 | Observe que a resposta precisa ser uma substring — "pwke" é uma subsequência, e não uma substring. -------------------------------------------------------------------------------- /problems/solutions/0003-longest-substring-without-repeating-characters/solution.ts: -------------------------------------------------------------------------------- 1 | function lengthOfLongestSubstring(s: string): number { 2 | if(!s) return 0 3 | 4 | const max = new Set([1]) 5 | let dic = '' 6 | for(let i = 0; i 0` to avoid negatives 85 | - Every number from 1 to 9 is a palindrome. A single loop will be used. If 1 <= x <= 9, `divmod(x, 10)` → (0, x) 86 | - `while x` also works, but a conditional check is needed for negative numbers. 87 | -------------------------------------------------------------------------------- /problems/solutions/0009-palindrome-number/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 9. Palindrome Number (Fácil) 2 | 3 | Dado um número inteiro `x`, return` true` _if_`x` _is a_ _ ** palindrome ** _ _, 4 | e_`false` _otherwise_. 5 | 6 | ## Exemplo 1: 7 | 8 | 9 | 10 | Entrada: x = 121 11 | Saída: true 12 | Explicação: 121 lê como 121 da esquerda para a direita e da direita para a esquerda. 13 | 14 | 15 | ## Exemplo 2: 16 | 17 | 18 | 19 | Entrada: x = -121 20 | Saída: false 21 | Explicação: Da esquerda para a direita, lê -121.Da direita para a esquerda, torna-se 121-.Portanto, não é um palíndromo. 22 | 23 | 24 | ## Exemplo 3: 25 | 26 | 27 | 28 | Entrada: x = 10 29 | Saída: false 30 | Explicação: lê 01 da direita para a esquerda.Portanto, não é um palíndromo. 31 | 32 | 33 | ## restrições 34 | 35 | * `-231 <= x <= 231 - 1` 36 | 37 | ** Acompanhamento: ** Você poderia resolvê -lo sem converter o número inteiro em uma string? 38 | -------------------------------------------------------------------------------- /problems/solutions/0009-palindrome-number/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | ## 🔄 Como obter um palíndromo sem usar string? 2 | 3 | **Resposta:** Revertendo as casas numéricas. 4 | 5 | ### Exemplo: 6 | 121 pode ser reescrito como: 7 | 8 | ``` 9 | 100 + 20 + 1 10 | = (1 * 10**2) + (2 * 10**1) + (1 * 10**0) 11 | ``` 12 | 13 | - 100 é 1 na casa das centenas 14 | - 20 é 2 na casa das dezenas 15 | - 1 é 1 na casa das unidades 16 | 17 | Revertendo: 18 | 19 | - 1 da unidade vira da centena → 100 20 | - 2 da dezena continua → 20 21 | - 1 da centena vira da unidade → 1 22 | 23 | ➡️ 121 é igual a 121 (é um palíndromo) 24 | 25 | Outro exemplo: 26 | 122 → 100 + 20 + 2 27 | Revertendo → 200 + 20 + 1 → **122 ≠ 221** 28 | 29 | --- 30 | 31 | ### 🔢 Deduções 32 | 33 | Se dividimos por 10, obtemos a casa numérica. 34 | Como vamos do final para o início, precisamos também **multiplicar por 10** para inverter. 35 | 36 | No código, usamos o **próprio número passado no argumento da função**, porque **não sabemos quantas vezes será necessário fazer a operação**. 37 | Usamos `while` como loop para a operação. 38 | 39 | ``` 40 | 121 ÷ 10 → resto(%) = 1, quociente(//) = 12 41 | 12 ÷ 10 → resto(%) = 2, quociente(//) = 1 42 | 1 ÷ 10 → resto(%) = 1, quociente(//) = 0 43 | ``` 44 | 45 | - O resto representa o início da leitura reversa 46 | - O quociente será usado no loop seguinte até zerar 47 | 48 | --- 49 | 50 | Se fizermos apenas: 51 | ```python 52 | reverso += x % 10 53 | ``` 54 | Não adiantará, pois vamos apenas somar os dígitos: `1 + 2 + 1 = 4` 55 | 56 | ### ✅ Solução correta: 57 | 58 | A cada loop temos que acrescentar à casa numérica superior e não esquecer que x servirá como variável do loop: 59 | 60 | ```text 61 | x = 121, reverso = 0 62 | 63 | Loop 1 → reverso = 0 * 10 + 1 → 1 64 | Loop 2 → reverso = 1 * 10 + 2 → 12 65 | Loop 3 → reverso = 12 * 10 + 1 → 121 66 | ``` 67 | 68 | **Fórmula:** 69 | 70 | ```python 71 | reverso = reverso * 10 + x % 10 72 | x //= 10 73 | ``` 74 | 75 | --- 76 | 77 | ### 💡 Dicas úteis: 78 | 79 | - Para obter quociente e resto ao mesmo tempo: 80 | ```python 81 | q, r = divmod(x, 10) 82 | ``` 83 | 84 | - Use `while x > 0` para evitar negativos 85 | - Todo número de 1 a 9 é palíndromo. um único loop será usado. Se 1= (0, x) 86 | - `while x` também funciona, mas precisaria de uma condicional antes para números negativos. 87 | -------------------------------------------------------------------------------- /problems/solutions/0009-palindrome-number/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isPalindrome(self, x: int) -> bool: 3 | reverso, numero = 0, x 4 | while x > 0: 5 | reverso = reverso * 10 + x % 10 6 | x //= 10 7 | return reverso == numero 8 | -------------------------------------------------------------------------------- /problems/solutions/0013-roman-to-integer/en/description.md: -------------------------------------------------------------------------------- 1 | # 13. Roman to Integer (Easy) 2 | 3 | Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, 4 | `C`, `D` and `M`. 5 | 6 | Symbol Value 7 | I 1 8 | V 5 9 | X 10 10 | L 50 11 | C 100 12 | D 500 13 | M 1000 14 | 15 | For example, `2` is written as `II` in Roman numeral, just two ones added 16 | together. `12` is written as `XII`, which is simply `X + II`. The number `27` 17 | is written as `XXVII`, which is `XX + V + II`. 18 | 19 | Roman numerals are usually written largest to smallest from left to right. 20 | However, the numeral for four is not `IIII`. Instead, the number four is 21 | written as `IV`. Because the one is before the five we subtract it making 22 | four. The same principle applies to the number nine, which is written as `IX`. 23 | There are six instances where subtraction is used: 24 | 25 | - `I` can be placed before `V` (5) and `X` (10) to make 4 and 9. 26 | - `X` can be placed before `L` (50) and `C` (100) to make 40 and 90. 27 | - `C` can be placed before `D` (500) and `M` (1000) to make 400 and 900. 28 | 29 | Given a roman numeral, convert it to an integer. 30 | 31 | ## Example 1: 32 | 33 | Input: s = "III" 34 | Output: 3 35 | Explanation: III = 3. 36 | 37 | ## Example 2: 38 | 39 | Input: s = "LVIII" 40 | Output: 58 41 | Explanation: L = 50, V= 5, III = 3. 42 | 43 | ## Example 3: 44 | 45 | Input: s = "MCMXCIV" 46 | Output: 1994 47 | Explanation: M = 1000, CM = 900, XC = 90 and IV = 4. 48 | 49 | ## Constraints 50 | 51 | - `1 <= s.length <= 15` 52 | - `s` contains only the characters `('I', 'V', 'X', 'L', 'C', 'D', 'M')`. 53 | - It is **guaranteed** that `s` is a valid roman numeral in the range `[1, 3999]`. 54 | -------------------------------------------------------------------------------- /problems/solutions/0013-roman-to-integer/en/explanation.md: -------------------------------------------------------------------------------- 1 | # Explanation – Roman to Integer 2 | 3 | To solve the problem of converting a Roman numeral to an integer, we must understand the Roman numeral system and apply the correct logic based on its rules. 4 | 5 | ## Roman Numeral Values 6 | 7 | Roman numerals are made up of letters with corresponding integer values: 8 | 9 | | Symbol | Value | 10 | | ------ | ----- | 11 | | I | 1 | 12 | | V | 5 | 13 | | X | 10 | 14 | | L | 50 | 15 | | C | 100 | 16 | | D | 500 | 17 | | M | 1000 | 18 | 19 | ## How Roman Numerals Work 20 | 21 | Normally, values are **added from left to right**. 22 | For example: 23 | 24 | - `"III"` = 1 + 1 + 1 = **3** 25 | - `"XII"` = 10 + 1 + 1 = **12** 26 | - `"XXVII"` = 10 + 10 + 5 + 1 + 1 = **27** 27 | 28 | However, if a smaller value appears **before** a larger one, we **subtract** it. 29 | This rule applies to: 30 | 31 | - `I` before `V` (5) or `X` (10) → 4 and 9 32 | - `X` before `L` (50) or `C` (100) → 40 and 90 33 | - `C` before `D` (500) or `M` (1000) → 400 and 900 34 | 35 | For example: 36 | 37 | - `"IV"` = 5 - 1 = **4** 38 | - `"IX"` = 10 - 1 = **9** 39 | - `"XL"` = 50 - 10 = **40** 40 | - `"MCMXCIV"` = 1000 + (1000 - 100) + (100 - 10) + (5 - 1) = **1994** 41 | 42 | ## Solution Logic 43 | 44 | The algorithm uses the following approach: 45 | 46 | 1. Map all Roman symbols to their integer values. 47 | 2. Loop through the string comparing each character with the next one: 48 | - If the current value is **less than** the next, subtract it. 49 | - Otherwise, add it. 50 | 3. Add the value of the **last character** (it’s never subtracted). 51 | -------------------------------------------------------------------------------- /problems/solutions/0013-roman-to-integer/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 13. Romano para Inteiro (Fácil) 2 | 3 | Os números romanos são representados por sete símbolos diferentes: `I`, `V`, `X`, `L`, 4 | `C`, `D` e `M`. 5 | 6 | Símbolo Valor 7 | I 1 8 | V 5 9 | X 10 10 | L 50 11 | C 100 12 | D 500 13 | M 1000 14 | 15 | Por exemplo, o número `2` é escrito como `II` em algarismos romanos, ou seja, dois uns somados. 16 | O número `12` é escrito como `XII`, que é simplesmente `X + II`. O número `27` é escrito como `XXVII`, que é `XX + V + II`. 17 | 18 | Os números romanos geralmente são escritos do maior para o menor valor, da esquerda para a direita. 19 | No entanto, o número quatro não é escrito como `IIII`. Em vez disso, ele é escrito como `IV`. 20 | Como o `I` vem antes do `V`, subtraímos 1 de 5, resultando em 4. 21 | O mesmo princípio se aplica ao número nove, que é escrito como `IX`. 22 | 23 | Há seis situações em que a subtração é usada: 24 | 25 | - `I` pode ser colocado antes de `V` (5) e `X` (10) para formar 4 e 9. 26 | - `X` pode ser colocado antes de `L` (50) e `C` (100) para formar 40 e 90. 27 | - `C` pode ser colocado antes de `D` (500) e `M` (1000) para formar 400 e 900. 28 | 29 | Dado um número romano, converta-o para um número inteiro. 30 | 31 | ## Exemplo 1: 32 | 33 | Entrada: s = "III" 34 | Saída: 3 35 | Explicação: III = 3. 36 | 37 | ## Exemplo 2: 38 | 39 | Entrada: s = "LVIII" 40 | Saída: 58 41 | Explicação: L = 50, V = 5, III = 3. 42 | 43 | ## Exemplo 3: 44 | 45 | Entrada: s = "MCMXCIV" 46 | Saída: 1994 47 | Explicação: M = 1000, CM = 900, XC = 90 e IV = 4. 48 | 49 | ## Restrições 50 | 51 | - `1 <= s.length <= 15` 52 | - `s` contém apenas os caracteres `('I', 'V', 'X', 'L', 'C', 'D', 'M')`. 53 | - É **garantido** que `s` é um número romano válido no intervalo `[1, 3999]`. 54 | -------------------------------------------------------------------------------- /problems/solutions/0013-roman-to-integer/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # Explicação – Romano para Inteiro 2 | 3 | Para resolver o problema de converter um número romano para um inteiro, precisamos entender o sistema de numeração romana e aplicar a lógica correta com base em suas regras. 4 | 5 | ## Valores dos Algarismos Romanos 6 | 7 | Os algarismos romanos são compostos por letras com valores inteiros correspondentes: 8 | 9 | | Símbolo | Valor | 10 | | ------- | ----- | 11 | | I | 1 | 12 | | V | 5 | 13 | | X | 10 | 14 | | L | 50 | 15 | | C | 100 | 16 | | D | 500 | 17 | | M | 1000 | 18 | 19 | ## Como Funciona a Numeração Romana 20 | 21 | Normalmente, os valores são **somados da esquerda para a direita**. 22 | Por exemplo: 23 | 24 | - `"III"` = 1 + 1 + 1 = **3** 25 | - `"XII"` = 10 + 1 + 1 = **12** 26 | - `"XXVII"` = 10 + 10 + 5 + 1 + 1 = **27** 27 | 28 | Porém, se um valor menor aparece **antes** de um valor maior, devemos **subtrair** esse valor. 29 | Essa regra se aplica às seguintes combinações: 30 | 31 | - `I` antes de `V` (5) ou `X` (10) → 4 e 9 32 | - `X` antes de `L` (50) ou `C` (100) → 40 e 90 33 | - `C` antes de `D` (500) ou `M` (1000) → 400 e 900 34 | 35 | Por exemplo: 36 | 37 | - `"IV"` = 5 - 1 = **4** 38 | - `"IX"` = 10 - 1 = **9** 39 | - `"XL"` = 50 - 10 = **40** 40 | - `"MCMXCIV"` = 1000 + (1000 - 100) + (100 - 10) + (5 - 1) = **1994** 41 | 42 | ## Lógica da Solução 43 | 44 | O algoritmo segue os seguintes passos: 45 | 46 | 1. Mapeia todos os símbolos romanos com seus respectivos valores inteiros. 47 | 2. Percorre a string comparando cada caractere com o próximo: 48 | - Se o valor atual for **menor** que o próximo, subtrai. 49 | - Caso contrário, soma normalmente. 50 | 3. Soma o valor do **último caractere** (ele nunca será subtraído). 51 | -------------------------------------------------------------------------------- /problems/solutions/0013-roman-to-integer/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def romanToInt(self, s: str) -> int: 3 | res = 0 4 | roman = { 5 | 'I': 1, 6 | 'V': 5, 7 | 'X': 10, 8 | 'L': 50, 9 | 'C': 100, 10 | 'D': 500, 11 | 'M': 1000 12 | } 13 | 14 | for a, b in zip(s, s[1:]): 15 | if roman[a] < roman[b]: 16 | res -= roman[a] 17 | else: 18 | res += roman[a] 19 | 20 | return res + roman[s[-1]] -------------------------------------------------------------------------------- /problems/solutions/0013-roman-to-integer/solution.ts: -------------------------------------------------------------------------------- 1 | class Solution{} 2 | function romanToInt(s: string): number { 3 | 4 | const valores: { [key: string]: number } = { 5 | 'I': 1, 6 | 'V': 5, 7 | 'X': 10, 8 | 'L': 50, 9 | 'C': 100, 10 | 'D': 500, 11 | 'M': 1000 12 | }; 13 | 14 | let total = 0; // Declarando a Variavel: Total 15 | let anterior = 0; // Declarando a Variavel: Anterior 16 | 17 | for (let i = s.length - 1; i >= 0; i--) { 18 | const atual = valores[s[i]]; 19 | 20 | if (atual < anterior) { 21 | 22 | // Subtrai se o valor atual for menor que o anterior 23 | total -= atual; 24 | } else { 25 | // Soma normalmente 26 | total += atual; 27 | } 28 | 29 | // Atualiza o valor anterior para a próxima iteração 30 | 31 | anterior = atual; 32 | } 33 | 34 | return total; 35 | } 36 | -------------------------------------------------------------------------------- /problems/solutions/0014-longest-common-prefix/en/description.md: -------------------------------------------------------------------------------- 1 | # 14. Longest Common Prefix (Easy) 2 | 3 | Write a function to find the longest common prefix string amongst an array of 4 | strings. 5 | 6 | If there is no common prefix, return an empty string `""`. 7 | 8 | ## Example 1: 9 | 10 | Input: strs = ["flower","flow","flight"] 11 | Output: "fl" 12 | 13 | ## Example 2: 14 | 15 | Input: strs = ["dog","racecar","car"] 16 | Output: "" 17 | Explanation: There is no common prefix among the input strings. 18 | 19 | ## Constraints 20 | 21 | - `1 <= strs.length <= 200` 22 | - `0 <= strs[i].length <= 200` 23 | - `strs[i]` consists of only lowercase English letters if it is non-empty. 24 | -------------------------------------------------------------------------------- /problems/solutions/0014-longest-common-prefix/en/explanation.md: -------------------------------------------------------------------------------- 1 | # Explanation – Longest Common Prefix 2 | 3 | To solve the problem of finding the longest common prefix among a list of strings, we need to compare characters across all the strings and identify the maximum prefix shared by all of them. 4 | 5 | ## What Is a Prefix? 6 | 7 | A **prefix** is the beginning portion of a string. 8 | For example, in the word `"flower"`: 9 | 10 | - `"f"` is a prefix 11 | - `"flo"` is a prefix 12 | - `"flower"` is a prefix 13 | - `"l"` or `"lower"` are **not** prefixes (they don’t start the word) 14 | 15 | ## Problem Understanding 16 | 17 | Given an array of strings, the goal is to return the longest prefix that all the strings share. 18 | If no common prefix exists, return an empty string `""`. 19 | 20 | ## Examples 21 | 22 | - `["flower", "flow", "flight"]` → Common prefix is `"fl"` 23 | - `["dog", "racecar", "car"]` → No common prefix → `""` 24 | 25 | ## Solution Logic 26 | 27 | The algorithm uses the following approach: 28 | 29 | 1. Assume the **first string** is the initial common prefix. 30 | 2. Iterate over the remaining strings: 31 | - While the current string **does not start** with the current prefix: 32 | - Remove the last character from the prefix. 33 | - If the prefix becomes empty, return `""`. 34 | 3. Return the resulting prefix after all comparisons. 35 | 36 | ## Why This Works 37 | 38 | By iteratively shrinking the prefix until it matches the beginning of each word, we ensure that the final result is the longest common prefix that applies to **all** strings in the list. 39 | -------------------------------------------------------------------------------- /problems/solutions/0014-longest-common-prefix/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 14. Prefixo Comum Mais Longo (Fácil) 2 | 3 | Escreva uma função para encontrar a maior string que seja prefixo comum entre um array de strings. 4 | 5 | Se não houver um prefixo comum, retorne uma string vazia `""`. 6 | 7 | ## Exemplo 1: 8 | 9 | Entrada: strs = ["flower","flow","flight"] 10 | Saída: "fl" 11 | 12 | ## Exemplo 2: 13 | 14 | Entrada: strs = ["dog","racecar","car"] 15 | Saída: "" 16 | Explicação: Não há prefixo comum entre as strings fornecidas. 17 | 18 | ## Restrições 19 | 20 | - `1 <= strs.length <= 200` 21 | - `0 <= strs[i].length <= 200` 22 | - `strs[i]` consiste apenas em letras minúsculas do alfabeto inglês, se não estiver vazia. 23 | -------------------------------------------------------------------------------- /problems/solutions/0014-longest-common-prefix/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # Explicação – Prefixo Comum Mais Longo 2 | 3 | Para resolver o problema de encontrar o prefixo comum mais longo entre uma lista de strings, precisamos comparar os caracteres em todas as strings e identificar o maior prefixo compartilhado por todas elas. 4 | 5 | ## O que é um prefixo? 6 | 7 | Um **prefixo** é a parte inicial de uma string. 8 | Por exemplo, na palavra `"flor"`: 9 | 10 | - `"f"` é um prefixo 11 | - `"flo"` é um prefixo 12 | - `"flor"` é um prefixo 13 | - `"l"` ou `"lor"` **não** são prefixos (não iniciam a palavra) 14 | 15 | ## Entendendo o problema 16 | 17 | Dada uma lista de strings, o objetivo é retornar o maior prefixo que todas compartilham. 18 | Se nenhum prefixo comum existir, retorne uma string vazia `""`. 19 | 20 | ## Exemplos 21 | 22 | - `["flor", "fluxo", "flauta"]` → Prefixo comum: `"fl"` 23 | - `["cão", "rato", "carro"]` → Sem prefixo comum → `""` 24 | 25 | ## Lógica da Solução 26 | 27 | O algoritmo segue a seguinte abordagem: 28 | 29 | 1. Assume a **primeira string** como o prefixo comum inicial. 30 | 2. Itera sobre as demais strings: 31 | - Enquanto a string atual **não começar** com o prefixo: 32 | - Remove o último caractere do prefixo. 33 | - Se o prefixo se tornar vazio, retorna `""`. 34 | 3. Retorna o prefixo final após todas as comparações. 35 | 36 | ## Por que isso funciona 37 | 38 | Ao reduzir iterativamente o prefixo até que ele corresponda ao início de cada palavra, garantimos que o resultado final seja o maior prefixo comum que se aplica a **todas** as strings da lista. 39 | -------------------------------------------------------------------------------- /problems/solutions/0014-longest-common-prefix/solution.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | class Solution: 4 | def longestCommonPrefix(self, strs: List[str]) -> str: 5 | if not strs: 6 | return "" 7 | 8 | prefix = strs[0] 9 | 10 | for word in strs[1:]: 11 | while not word.startswith(prefix): 12 | prefix = prefix[:-1] 13 | if not prefix: 14 | return "" 15 | 16 | return prefix 17 | -------------------------------------------------------------------------------- /problems/solutions/0020-valid-parentheses/en/description.md: -------------------------------------------------------------------------------- 1 | # 20. Valid Parentheses (Easy) 2 | 3 | Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, 4 | `'['` and `']'`, determine if the input string is valid. 5 | 6 | An input string is valid if: 7 | 8 | 1. Open brackets must be closed by the same type of brackets. 9 | 2. Open brackets must be closed in the correct order. 10 | 3. Every close bracket has a corresponding open bracket of the same type. 11 | 12 | ## Example 1: 13 | 14 | Input: s = "()" 15 | 16 | Output: true 17 | 18 | ## Example 2: 19 | 20 | Input: s = "()[]{}" 21 | 22 | Output: true 23 | 24 | ## Example 3: 25 | 26 | Input: s = "(]" 27 | 28 | Output: false 29 | 30 | ## Example 4: 31 | 32 | Input: s = "([])" 33 | 34 | Output: true 35 | 36 | ## Constraints 37 | 38 | - `1 <= s.length <= 104` 39 | - `s` consists of parentheses only `'()[]{}'`. 40 | -------------------------------------------------------------------------------- /problems/solutions/0020-valid-parentheses/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 20. Valid Parentheses - Solution Explanation 2 | 3 | ## Approach: Using Stack Data Structure 4 | 5 | This solution uses a stack data structure to verify if a string containing only parentheses, brackets, and braces is valid, meaning each opening character has its corresponding closing character in the correct order. 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. We create an empty stack to store the opening characters. 10 | 2. We define a map that associates each closing character with its corresponding opening character. 11 | 3. We iterate through each character in the string: 12 | - If it's an opening character ('(', '{', '['), we push it onto the stack. 13 | - If it's a closing character (')', '}', ']'): 14 | - We check if the stack is empty (no pending opening characters). 15 | - We pop the last opening character and check if it corresponds to the current closing character. 16 | - If either of these checks fails, the string is not valid. 17 | 4. At the end, the string is only valid if the stack is empty (all opening characters have been closed). 18 | 19 | ## Step-by-Step Example: 20 | 21 | Using the example: `s = "({[]})"`. 22 | 23 | 1. Initialization: 24 | 25 | - `stack = []` 26 | - `bracketMap = { ")": "(", "}": "{", "]": "[" }` 27 | 28 | 2. Iteration: 29 | 30 | - `char = '('`: It's an opening character, push to stack. `stack = ['(']` 31 | - `char = '{'`: It's an opening character, push to stack. `stack = ['(', '{']` 32 | - `char = '['`: It's an opening character, push to stack. `stack = ['(', '{', '[']` 33 | - `char = ']'`: It's a closing character: 34 | - Pop the last character: `'['` 35 | - Check if `bracketMap[']'] === '['` (true) 36 | - `stack = ['(', '{']` 37 | - `char = '}'`: It's a closing character: 38 | - Pop the last character: `'{'` 39 | - Check if `bracketMap['}'] === '{'` (true) 40 | - `stack = ['(']` 41 | - `char = ')'`: It's a closing character: 42 | - Pop the last character: `'('` 43 | - Check if `bracketMap[')'] === '('` (true) 44 | - `stack = []` 45 | 46 | 3. At the end, we check if `stack.length === 0` (true), so the string is valid. 47 | -------------------------------------------------------------------------------- /problems/solutions/0020-valid-parentheses/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 20. Valid Parentheses 2 | 3 | Dada uma string `s` contendo apenas os personagens`'('`,`')'`,`'{'`,`'}'`, 4 | `'['` e `']'`, determine se a sequência de entrada é válida. 5 | 6 | Uma sequência de entrada é válida se: 7 | 8 | 1. Suportes abertos devem ser fechados pelo mesmo tipo de colchetes. 9 | 2. Os suportes abertos devem ser fechados na ordem correta. 10 | 3. Todo suporte próximo possui um suporte aberto correspondente do mesmo tipo. 11 | 12 | ## Exemplo 1: 13 | 14 | Entrada: s = "()" 15 | 16 | Saída: true 17 | 18 | ## Exemplo 2: 19 | 20 | Entrada: s = "() [] {}" 21 | 22 | Saída: true 23 | 24 | ## Exemplo 3: 25 | 26 | Entrada: s = "(]" 27 | 28 | Saída: false 29 | 30 | ## Exemplo 4: 31 | 32 | Entrada: s = "([])" 33 | 34 | Saída: true 35 | 36 | ## restrições 37 | 38 | - `1 <= S.Length <= 104` 39 | - `s` consiste em apenas parênteses`'() [] {}'`. 40 | -------------------------------------------------------------------------------- /problems/solutions/0020-valid-parentheses/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 20. Valid Parentheses - Explicação da Solução 2 | 3 | ## Abordagem: Utilizando Pilha (Stack) 4 | 5 | Esta solução utiliza uma estrutura de dados de pilha para verificar se uma string contendo apenas parênteses, colchetes e chaves está válida, ou seja, se cada caractere de abertura tem seu correspondente de fechamento na ordem correta. 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. Criamos uma pilha vazia para armazenar os caracteres de abertura. 10 | 2. Definimos um mapa que associa cada caractere de fechamento ao seu correspondente de abertura. 11 | 3. Percorremos cada caractere da string: 12 | - Se for um caractere de abertura ('(', '{', '['), o empilhamos. 13 | - Se for um caractere de fechamento (')', '}', ']'): 14 | - Verificamos se a pilha está vazia (não há caracteres de abertura pendentes). 15 | - Desempilhamos o último caractere de abertura e verificamos se corresponde ao atual caractere de fechamento. 16 | - Se alguma dessas verificações falhar, a string não é válida. 17 | 4. Ao final, a string só é válida se a pilha estiver vazia (todos os caracteres de abertura foram fechados). 18 | 19 | ## Exemplo Passo a Passo: 20 | 21 | Usando o exemplo: `s = "({[]})"`. 22 | 23 | 1. Inicialização: 24 | 25 | - `stack = []` 26 | - `bracketMap = { ")": "(", "}": "{", "]": "[" }` 27 | 28 | 2. Iteração: 29 | 30 | - `char = '('`: É um caractere de abertura, empilhamos. `stack = ['(']` 31 | - `char = '{'`: É um caractere de abertura, empilhamos. `stack = ['(', '{']` 32 | - `char = '['`: É um caractere de abertura, empilhamos. `stack = ['(', '{', '[']` 33 | - `char = ']'`: É um caractere de fechamento: 34 | - Desempilhamos o último caractere: `'['` 35 | - Verificamos se `bracketMap[']'] === '['` (verdadeiro) 36 | - `stack = ['(', '{']` 37 | - `char = '}'`: É um caractere de fechamento: 38 | - Desempilhamos o último caractere: `'{'` 39 | - Verificamos se `bracketMap['}'] === '{'` (verdadeiro) 40 | - `stack = ['(']` 41 | - `char = ')'`: É um caractere de fechamento: 42 | - Desempilhamos o último caractere: `'('` 43 | - Verificamos se `bracketMap[')'] === '('` (verdadeiro) 44 | - `stack = []` 45 | 46 | 3. Ao final, verificamos se `stack.length === 0` (verdadeiro), então a string é válida. 47 | -------------------------------------------------------------------------------- /problems/solutions/0020-valid-parentheses/solution.ts: -------------------------------------------------------------------------------- 1 | function isValid(s: string): boolean { 2 | const stack: string[] = []; 3 | const bracketMap = { 4 | ")": "(", 5 | "}": "{", 6 | "]": "[", 7 | }; 8 | 9 | for (let char of s) { 10 | if (char === "(" || char === "{" || char === "[") { 11 | stack.push(char); 12 | } else { 13 | if (stack.length === 0 || stack.pop() !== bracketMap[char]) { 14 | return false; 15 | } 16 | } 17 | } 18 | 19 | return stack.length === 0; 20 | } 21 | -------------------------------------------------------------------------------- /problems/solutions/0021-merge-two-sorted-lists/en/description.md: -------------------------------------------------------------------------------- 1 | # 21. Merge Two Sorted Lists (Easy) 2 | 3 | You are given the heads of two sorted linked lists `list1` and `list2`. 4 | 5 | Merge the two lists into one **sorted** list. The list should be made by 6 | splicing together the nodes of the first two lists. 7 | 8 | Return _the head of the merged linked list_. 9 | 10 | ## Example 1: 11 | 12 | ![](https://assets.leetcode.com/uploads/2020/10/03/merge_ex1.jpg) 13 | 14 | 15 | 16 | Input: list1 = [1,2,4], list2 = [1,3,4] 17 | Output: [1,1,2,3,4,4] 18 | 19 | 20 | ## Example 2: 21 | 22 | 23 | 24 | Input: list1 = [], list2 = [] 25 | Output: [] 26 | 27 | 28 | ## Example 3: 29 | 30 | 31 | 32 | Input: list1 = [], list2 = [0] 33 | Output: [0] 34 | 35 | 36 | ## Constraints 37 | 38 | * The number of nodes in both lists is in the range `[0, 50]`. 39 | * `-100 <= Node.val <= 100` 40 | * Both `list1` and `list2` are sorted in **non-decreasing** order. 41 | -------------------------------------------------------------------------------- /problems/solutions/0021-merge-two-sorted-lists/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 21. Combinar Duas Listas Ordenadas (Fácil) 2 | 3 | Você recebe os **cabeçalhos** de duas **listas encadeadas ordenadas**, `list1` e `list2`. 4 | 5 | Combine as duas listas em uma única lista **ordenada**. A lista deve ser formada unindo os nós das duas primeiras listas. 6 | 7 | Retorne _o cabeçalho da lista encadeada combinada_. 8 | 9 | ## Exemplo 1: 10 | 11 | ![](https://assets.leetcode.com/uploads/2020/10/03/merge_ex1.jpg) 12 | 13 | Input: list1 = [1,2,4], list2 = [1,3,4] 14 | Output: [1,1,2,3,4,4] 15 | 16 | 17 | ## Exemplo 2: 18 | 19 | Input: list1 = [], list2 = [] 20 | Output: [] 21 | 22 | 23 | ## Exemplo 3: 24 | 25 | Input: list1 = [], list2 = [0] 26 | Output: [0] 27 | 28 | 29 | ## Restrições 30 | 31 | * O número de nós em ambas as listas está no intervalo `[0, 50]`. 32 | * `-100 <= Node.val <= 100` 33 | * Ambas `list1` e `list2` estão ordenadas em ordem **não decrescente**. -------------------------------------------------------------------------------- /problems/solutions/0021-merge-two-sorted-lists/solution.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | # Definition for singly-linked list. 3 | class ListNode: 4 | def __init__(self, val=0, next=None): 5 | self.val = val 6 | self.next = next 7 | class Solution: 8 | def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]: 9 | new_list = ListNode() 10 | tail= new_list 11 | while list1 and list2: 12 | if list1.val < list2.val: 13 | tail.next = list1 14 | list1 = list1.next 15 | 16 | else: 17 | tail.next = list2 18 | list2 = list2.next 19 | tail = tail.next 20 | 21 | if list1: 22 | tail.next = list1 23 | 24 | elif list2: 25 | tail.next = list2 26 | 27 | return new_list.next -------------------------------------------------------------------------------- /problems/solutions/0035-search-insert-position/en/description.md: -------------------------------------------------------------------------------- 1 | # 35. Search Insert Position (Easy) 2 | 3 | Given a sorted array of distinct integers and a target value, return the index 4 | if the target is found. If not, return the index where it would be if it were 5 | inserted in order. 6 | 7 | You must write an algorithm with `O(log n)` runtime complexity. 8 | 9 | ## Example 1: 10 | 11 | Input: nums = [1,3,5,6], target = 5 12 | Output: 2 13 | 14 | ## Example 2: 15 | 16 | Input: nums = [1,3,5,6], target = 2 17 | Output: 1 18 | 19 | ## Example 3: 20 | 21 | Input: nums = [1,3,5,6], target = 7 22 | Output: 4 23 | 24 | ## Constraints 25 | 26 | - `1 <= nums.length <= 104` 27 | - `-104 <= nums[i] <= 104` 28 | - `nums` contains **distinct** values sorted in **ascending** order. 29 | - `-104 <= target <= 104` 30 | -------------------------------------------------------------------------------- /problems/solutions/0035-search-insert-position/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 35. Search Insert Position - Solution Explanation 2 | 3 | ## Approach: Linear Search with Neighbor Check 4 | 5 | This solution uses a linear search approach to find the correct position to insert a target value into a sorted array. It examines each element and its neighbor to determine the proper insertion point. 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. We initialize a variable `finalIndex` to 0 (default position if all elements are greater than the target). 10 | 2. We iterate through each index of the array: 11 | - We convert the string index from `for...in` loop to a number. 12 | - We get the current element and its next element (which may be undefined if we're at the end). 13 | 3. We handle two main cases: 14 | - Case 1: If we find the exact match for the target, we record this index. 15 | - Case 2: If the target is greater than the current element, we check: 16 | - If the next element is greater than or equal to the target, OR 17 | - If there is no next element (we're at the end of the array) 18 | - Then the target should be inserted right after the current element. 19 | 4. We return the final determined index position. 20 | 21 | ## Example Step-by-Step: 22 | 23 | Using example: `nums = [1,3,5,6]`, `target = 5` 24 | 25 | 1. Initialization: 26 | 27 | - `finalIndex = 0` 28 | 29 | 2. Iteration: 30 | 31 | - Index 0: 32 | - `currentNumber = 1`, `nextNumber = 3` 33 | - `1 < 5`, and `3 < 5`, so no update to finalIndex 34 | - Index 1: 35 | - `currentNumber = 3`, `nextNumber = 5` 36 | - `3 < 5`, and `5 >= 5`, so `finalIndex = 2` 37 | - Index 2: 38 | - `currentNumber = 5`, `nextNumber = 6` 39 | - `5 === 5`, so `finalIndex = 2` (exact match found) 40 | - Index 3: 41 | - `currentNumber = 6`, `nextNumber = undefined` 42 | - `6 > 5`, so no update to finalIndex 43 | 44 | 3. Return `finalIndex = 2` 45 | -------------------------------------------------------------------------------- /problems/solutions/0035-search-insert-position/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 35. Posição de Inserção de Busca (Fácil) 2 | 3 | Dado um array ordenado de inteiros distintos e um valor alvo, retorne o índice 4 | se o valor alvo for encontrado. Caso contrário, retorne o índice onde ele estaria 5 | se fosse inserido na ordem correta. 6 | 7 | Você deve escrever um algoritmo com complexidade de tempo `O(log n)`. 8 | 9 | ## Exemplo 1: 10 | 11 | Entrada: nums = [1,3,5,6], target = 5 12 | Saída: 2 13 | 14 | ## Exemplo 2: 15 | 16 | Entrada: nums = [1,3,5,6], target = 2 17 | Saída: 1 18 | 19 | ## Exemplo 3: 20 | 21 | Entrada: nums = [1,3,5,6], target = 7 22 | Saída: 4 23 | 24 | ## Restrições 25 | 26 | - `1 <= nums.length <= 10⁴` 27 | - `-10⁴ <= nums[i] <= 10⁴` 28 | - `nums` contém valores **distintos** ordenados em **ordem crescente**. 29 | - `-10⁴ <= target <= 10⁴` 30 | -------------------------------------------------------------------------------- /problems/solutions/0035-search-insert-position/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 35. Search Insert Position - Explicação da Solução 2 | 3 | ## Abordagem: Busca Linear com Verificação de Vizinhos 4 | 5 | Esta solução utiliza uma abordagem de busca linear para encontrar a posição correta para inserir um valor alvo em um array ordenado. Ela examina cada elemento e seu vizinho para determinar o ponto de inserção adequado. 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. Inicializamos uma variável `finalIndex` como 0 (posição padrão se todos os elementos forem maiores que o alvo). 10 | 2. Iteramos por cada índice do array: 11 | - Convertemos o índice string do loop `for...in` para um número. 12 | - Obtemos o elemento atual e seu próximo elemento (que pode ser indefinido se estivermos no final). 13 | 3. Lidamos com dois casos principais: 14 | - Caso 1: Se encontrarmos uma correspondência exata para o alvo, registramos este índice. 15 | - Caso 2: Se o alvo for maior que o elemento atual, verificamos: 16 | - Se o próximo elemento é maior ou igual ao alvo, OU 17 | - Se não há próximo elemento (estamos no final do array) 18 | - Então o alvo deve ser inserido logo após o elemento atual. 19 | 4. Retornamos a posição de índice final determinada. 20 | 21 | ## Exemplo Passo a Passo: 22 | 23 | Usando o exemplo: `nums = [1,3,5,6]`, `target = 5` 24 | 25 | 1. Inicialização: 26 | 27 | - `finalIndex = 0` 28 | 29 | 2. Iteração: 30 | 31 | - Índice 0: 32 | - `currentNumber = 1`, `nextNumber = 3` 33 | - `1 < 5`, e `3 < 5`, então não atualizamos o finalIndex 34 | - Índice 1: 35 | - `currentNumber = 3`, `nextNumber = 5` 36 | - `3 < 5`, e `5 >= 5`, então `finalIndex = 2` 37 | - Índice 2: 38 | - `currentNumber = 5`, `nextNumber = 6` 39 | - `5 === 5`, então `finalIndex = 2` (correspondência exata encontrada) 40 | - Índice 3: 41 | - `currentNumber = 6`, `nextNumber = undefined` 42 | - `6 > 5`, então não atualizamos o finalIndex 43 | 44 | 3. Retornamos `finalIndex = 2` 45 | -------------------------------------------------------------------------------- /problems/solutions/0035-search-insert-position/solution.ts: -------------------------------------------------------------------------------- 1 | function searchInsert(nums: number[], target: number): number { 2 | // Initialize the result index to 0 by default. 3 | // If all elements are greater than target, we’ll return 0. 4 | let finalIndex = 0; 5 | 6 | // Iterate over all indices in the array. 7 | // Note: using `for…in` gives string keys, so we convert to Number. 8 | for (const num in nums) { 9 | const index = Number(num); 10 | 11 | // Current element at position `index` 12 | const currentNumber = nums[index]; 13 | // Next element in sequence (may be undefined if index is at end) 14 | const nextNumber = nums[index + 1]; 15 | 16 | // Case 1: If we find the target exactly, record its index. 17 | if (currentNumber === target) { 18 | finalIndex = index; 19 | } 20 | 21 | // Case 2: If target is greater than currentNumber... 22 | if (currentNumber < target) { 23 | // …and either the next element is >= target, or there's no next element, 24 | // then target should be inserted right after currentNumber. 25 | if (nextNumber >= target || typeof nextNumber === "undefined") { 26 | finalIndex = index + 1; 27 | } 28 | } 29 | } 30 | 31 | // Return the resolved index where target is found or should be inserted. 32 | return finalIndex; 33 | } 34 | -------------------------------------------------------------------------------- /problems/solutions/0070-climbing-stairs/en/description.md: -------------------------------------------------------------------------------- 1 | # 70. Climbing Stairs (Easy) 2 | 3 | You are climbing a staircase. It takes `n` steps to reach the top. 4 | 5 | Each time you can either climb `1` or `2` steps. In how many distinct ways can 6 | you climb to the top? 7 | 8 | ## Example 1: 9 | 10 | 11 | 12 | Input: n = 2 13 | Output: 2 14 | Explanation: There are two ways to climb to the top. 15 | 1. 1 step + 1 step 16 | 2. 2 steps 17 | 18 | 19 | ## Example 2: 20 | 21 | 22 | 23 | Input: n = 3 24 | Output: 3 25 | Explanation: There are three ways to climb to the top. 26 | 1. 1 step + 1 step + 1 step 27 | 2. 1 step + 2 steps 28 | 3. 2 steps + 1 step 29 | 30 | 31 | ## Constraints 32 | 33 | * `1 <= n <= 45` 34 | -------------------------------------------------------------------------------- /problems/solutions/0070-climbing-stairs/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 70. Climbing Stairs – Solution Explanation 2 | 3 | ## Approach: Iterative Dynamic Programming (Fibonacci-Style) 4 | 5 | This solution treats the number of ways to climb \(n\) stairs as the \(n\)th number in a sequence that follows the same recurrence as the Fibonacci numbers. Each step can be reached either from one step below or two steps below. By building up from the base cases, we avoid the exponential blow-up of naive recursion. 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. **Base cases** 10 | 11 | - If \(n \le 2\), there are exactly \(n\) ways to climb: 12 | - \(n=1\): \([1]\) → 1 way 13 | - \(n=2\): \([1+1], [2]\) → 2 ways 14 | 15 | 2. **Initialization** 16 | 17 | - Let `first = 1` represent the number of ways to reach step 1. 18 | - Let `second = 2` represent the number of ways to reach step 2. 19 | 20 | 3. **Iteration (Bottom-Up)** 21 | 22 | - For each step \(i\) from 3 to \(n\): 23 | 1. The number of ways to reach step \(i\) equals the sum of ways to reach steps \(i-1\) and \(i-2\). 24 | 2. Update: 25 | ```python 26 | first, second = second, first + second 27 | ``` 28 | - After this, `second` holds the number of ways to reach the current step \(i\), and `first` holds the previous value. 29 | 30 | 4. **Return** 31 | - After the loop, `second` is the number of ways to reach step \(n\). 32 | 33 | ## Example Step-by-Step: 34 | 35 | Let’s walk through `n = 5`. 36 | 37 | 1. **Base setup** 38 | 39 | - `first = 1` (ways to reach step 1) 40 | - `second = 2` (ways to reach step 2) 41 | 42 | 2. **Iteration** 43 | 44 | - **i = 3** 45 | - new ways = `first + second = 1 + 2 = 3` 46 | - update → `first = 2`, `second = 3` 47 | - **i = 4** 48 | - new ways = `2 + 3 = 5` 49 | - update → `first = 3`, `second = 5` 50 | - **i = 5** 51 | - new ways = `3 + 5 = 8` 52 | - update → `first = 5`, `second = 8` 53 | 54 | 3. **Result** 55 | - Return `second = 8`. 56 | - There are 8 distinct ways to climb 5 stairs: 57 | ``` 58 | 1+1+1+1+1 59 | 1+1+1+2 60 | 1+1+2+1 61 | 1+2+1+1 62 | 2+1+1+1 63 | 1+2+2 64 | 2+1+2 65 | 2+2+1 66 | ``` 67 | -------------------------------------------------------------------------------- /problems/solutions/0070-climbing-stairs/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 70. Climbing Stairs (Fácil) 2 | 3 | Você está escalando uma escada.São necessárias etapas `n` para chegar ao topo. 4 | 5 | Cada vez que você pode escalar etapas `1` ou` 2 '.De quantas maneiras distintas podem 6 | Você subiu para o topo? 7 | 8 | ## Exemplo 1: 9 | 10 | 11 | 12 | Entrada: n = 2 13 | Saída: 2 14 | Explicação: Existem duas maneiras de subir ao topo. 15 | 1. 1 etapa + 1 etapa 16 | 2. 2 etapas 17 | 18 | 19 | ## Exemplo 2: 20 | 21 | 22 | 23 | Entrada: n = 3 24 | Saída: 3 25 | Explicação: Existem três maneiras de subir ao topo. 26 | 1. 1 etapa + 1 etapa + 1 etapa 27 | 2. 1 etapa + 2 etapas 28 | 3. 2 etapas + 1 etapa 29 | 30 | 31 | ## restrições 32 | 33 | * `1 <= n <= 45` 34 | -------------------------------------------------------------------------------- /problems/solutions/0070-climbing-stairs/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 70. Subindo Escadas – Explicação da Solução 2 | 3 | ## Abordagem: Programação Dinâmica Iterativa (Estilo Fibonacci) 4 | 5 | Tratamos o número de maneiras de subir \(n\) degraus como o \(n\)-ésimo termo de uma sequência que segue a mesma relação de recorrência dos números de Fibonacci. Cada degrau pode ser alcançado vindo de um degrau anterior ou de dois degraus anteriores. Construindo a solução de baixo para cima, evitamos a explosão exponencial da recursão ingênua. 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. **Casos base** 10 | 11 | - Se \(n \le 2\), existem exatamente \(n\) maneiras de subir: 12 | - \(n=1\): \([1]\) → 1 maneira 13 | - \(n=2\): \([1+1], [2]\) → 2 maneiras 14 | 15 | 2. **Inicialização** 16 | 17 | - `first = 1` representa o número de maneiras de chegar ao degrau 1. 18 | - `second = 2` representa o número de maneiras de chegar ao degrau 2. 19 | 20 | 3. **Iteração (Bottom-Up)** 21 | 22 | - Para cada degrau \(i\) de 3 até \(n\): 23 | 1. As maneiras de chegar no degrau \(i\) são a soma das maneiras de chegar em \(i-1\) e \(i-2\). 24 | 2. Atualize: 25 | ```python 26 | first, second = second, first + second 27 | ``` 28 | - Após isso, `second` contém as maneiras de alcançar o degrau atual \(i\), e `first` mantém o valor anterior. 29 | 30 | 4. **Retorno** 31 | - Ao final do loop, `second` é o número de maneiras de alcançar o degrau \(n\). 32 | 33 | ## Exemplo Passo a Passo: 34 | 35 | Para `n = 5`: 36 | 37 | 1. **Configuração inicial** 38 | 39 | - `first = 1` (maneiras de alcançar o degrau 1) 40 | - `second = 2` (maneiras de alcançar o degrau 2) 41 | 42 | 2. **Iteração** 43 | 44 | - **i = 3** 45 | - novas maneiras = `first + second = 1 + 2 = 3` 46 | - atualiza → `first = 2`, `second = 3` 47 | - **i = 4** 48 | - novas maneiras = `2 + 3 = 5` 49 | - atualiza → `first = 3`, `second = 5` 50 | - **i = 5** 51 | - novas maneiras = `3 + 5 = 8` 52 | - atualiza → `first = 5`, `second = 8` 53 | 54 | 3. **Resultado** 55 | - Retorna `second = 8`. 56 | - Existem 8 maneiras distintas de subir 5 degraus: 57 | ``` 58 | 1+1+1+1+1 59 | 1+1+1+2 60 | 1+1+2+1 61 | 1+2+1+1 62 | 2+1+1+1 63 | 1+2+2 64 | 2+1+2 65 | 2+2+1 66 | ``` 67 | -------------------------------------------------------------------------------- /problems/solutions/0070-climbing-stairs/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def climbStairs(self, n: int) -> int: 3 | if n <= 2: 4 | return n 5 | 6 | first, second = 1, 2 7 | for _ in range(3, n + 1): 8 | first, second = second, first + second 9 | 10 | return second 11 | -------------------------------------------------------------------------------- /problems/solutions/0112-path-sum/en/description.md: -------------------------------------------------------------------------------- 1 | # 112. Path Sum (Easy) 2 | 3 | Given the `root` of a binary tree and an integer `targetSum`, return `true` if 4 | the tree has a **root-to-leaf** path such that adding up all the values along 5 | the path equals `targetSum`. 6 | 7 | A **leaf** is a node with no children. 8 | 9 | ## Example 1: 10 | 11 | ![](https://assets.leetcode.com/uploads/2021/01/18/pathsum1.jpg) 12 | 13 | 14 | 15 | Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22 16 | Output: true 17 | Explanation: The root-to-leaf path with the target sum is shown. 18 | 19 | 20 | ## Example 2: 21 | 22 | ![](https://assets.leetcode.com/uploads/2021/01/18/pathsum2.jpg) 23 | 24 | 25 | 26 | Input: root = [1,2,3], targetSum = 5 27 | Output: false 28 | Explanation: There are two root-to-leaf paths in the tree: 29 | (1 --> 2): The sum is 3. 30 | (1 --> 3): The sum is 4. 31 | There is no root-to-leaf path with sum = 5. 32 | 33 | 34 | ## Example 3: 35 | 36 | 37 | 38 | Input: root = [], targetSum = 0 39 | Output: false 40 | Explanation: Since the tree is empty, there are no root-to-leaf paths. 41 | 42 | 43 | ## Constraints 44 | 45 | * The number of nodes in the tree is in the range `[0, 5000]`. 46 | * `-1000 <= Node.val <= 1000` 47 | * `-1000 <= targetSum <= 1000` 48 | -------------------------------------------------------------------------------- /problems/solutions/0112-path-sum/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 112. Path Sum (Easy) 2 | 3 | ## Problem 4 | Given the `root` of a binary tree and an integer `targetSum`, return `True` if the tree has a root-to-leaf path such that adding up all the values along the path equals `targetSum`. A leaf is a node with no children. 5 | 6 | ## Examples 7 | 1. **Input:** 8 | root = [5,4,8,11,null,13,4,7,2,null,null,null,1], 9 | targetSum = 22 10 | 11 | Copiar 12 | Editar 13 | **Output:** `True` 14 | **Explanation:** The path 5 → 4 → 11 → 2 sums to 22. 15 | 16 | 2. **Input:** 17 | root = [1,2,3], 18 | targetSum = 5 19 | 20 | pgsql 21 | Copiar 22 | Editar 23 | **Output:** `False` 24 | **Explanation:** No root-to-leaf path sums to 5. 25 | 26 | 3. **Input:** 27 | root = [], 28 | targetSum = 0 29 | 30 | Copiar 31 | Editar 32 | **Output:** `False` 33 | **Explanation:** Empty tree has no paths. 34 | 35 | ## Approach 36 | 1. If `root` is `None`, return `False` (no path). 37 | 2. Store `val = root.val`, `left = root.left`, `right = root.right`. 38 | 3. If both `left` and `right` are `None` (leaf), check if `targetSum - val == 0`. 39 | 4. Otherwise, subtract `val` from `targetSum` and recursively check: 40 | - `hasPathSum(root.left, targetSum - val)` 41 | - OR `hasPathSum(root.right, targetSum - val)`. 42 | 5. Return `True` if either subtree returns `True`; else `False`. 43 | 44 | ## Complexity Analysis 45 | - **Time Complexity:** O(n), where n is the number of nodes; each node is visited once. 46 | - **Space Complexity:** O(h), where h is the tree height due to recursion stack (worst-case O(n) if unbalanced, O(log n) if balanced). -------------------------------------------------------------------------------- /problems/solutions/0112-path-sum/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 112. Path Sum (Fácil) 2 | 3 | Dada a 'raiz' de uma árvore binária e um número inteiro `tiraSum`, retornar 4 | A árvore tem um caminho de ** raiz para folhas **, de modo que somente todos os valores 5 | O caminho é igual ao `TargetSum`. 6 | 7 | A ** Folha ** é um nó sem filhos. 8 | 9 | ## Exemplo 1: 10 | 11 | ! [] (https://assets.leetcode.com/uploads/2021/01/18/pathsum1.jpg) 12 | 13 | 14 | 15 | Entrada: raiz = [5,4,8,11, nulo, 13,4,7,2, nulo, nulo, nulo, 1], TargetSum = 22 16 | Saída: true 17 | Explicação: O caminho da raiz a folha com a soma alvo é mostrado. 18 | 19 | 20 | ## Exemplo 2: 21 | 22 | ! [] (https://assets.leetcode.com/uploads/2021/01/18/pathsum2.jpg) 23 | 24 | 25 | 26 | Entrada: raiz = [1,2,3], TargetSum = 5 27 | Saída: false 28 | Explicação: Existem dois caminhos de raiz a folha na árvore: 29 | (1 -> 2): A soma é 3. 30 | (1 -> 3): A soma é 4. 31 | Não há caminho de raiz a folha com soma = 5. 32 | 33 | 34 | ## Exemplo 3: 35 | 36 | 37 | 38 | Entrada: root = [], TargetSum = 0 39 | Saída: false 40 | Explicação: Como a árvore está vazia, não há caminhos de raiz a folhas. 41 | 42 | 43 | ## restrições 44 | 45 | * O número de nós na árvore está no intervalo `[0, 5000]`. 46 | * `-1000 <= node.val <= 1000` 47 | * `-1000 <= TargetSum <= 1000` 48 | -------------------------------------------------------------------------------- /problems/solutions/0112-path-sum/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 112. Soma de Caminho (Fácil) 2 | 3 | ## Enunciado 4 | Dado o `root` de uma árvore binária e um inteiro `targetSum`, retorne `True` se existir um caminho da raiz até uma folha cuja soma dos valores seja igual a `targetSum`. Folha é um nó sem filhos. 5 | 6 | ## Exemplos 7 | 1. **Entrada:** 8 | root = [5,4,8,11,null,13,4,7,2,null,null,null,1], 9 | targetSum = 22 10 | 11 | Copiar 12 | Editar 13 | **Saída:** `True` 14 | **Explicação:** O caminho 5 → 4 → 11 → 2 soma 22. 15 | 16 | 2. **Entrada:** 17 | root = [1,2,3], 18 | targetSum = 5 19 | 20 | Copiar 21 | Editar 22 | **Saída:** `False` 23 | **Explicação:** Não há caminho da raiz até uma folha que some 5. 24 | 25 | 3. **Entrada:** 26 | root = [], 27 | targetSum = 0 28 | 29 | Copiar 30 | Editar 31 | **Saída:** `False` 32 | **Explicação:** Árvore vazia não possui caminhos. 33 | 34 | ## Abordagem 35 | 1. Se `root` for `None`, retorne `False` (não há caminho). 36 | 2. Defina `val = root.val`, `left = root.left` e `right = root.right`. 37 | 3. Se `left` e `right` forem `None` (nó folha), verifique se `targetSum - val == 0`. 38 | 4. Caso contrário, subtraia `val` de `targetSum` e chame recursivamente: 39 | - `hasPathSum(root.left, targetSum - val)` 40 | - OU `hasPathSum(root.right, targetSum - val)`. 41 | 5. Retorne `True` se qualquer chamada recursiva retornar `True`; caso contrário, retorne `False`. 42 | 43 | ## Análise de Complexidade 44 | - **Complexidade de Tempo:** O(n), onde n é o número de nós; cada nó é visitado uma vez. 45 | - **Complexidade de Espaço:** O(h), onde h é a altura da árvore devido à pilha de recursão (no pior caso O(n) se não estiver balanceada, O(log n) se estiver balanceada). -------------------------------------------------------------------------------- /problems/solutions/0112-path-sum/solution.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | class TreeNode: 4 | def __init__(self, val=0, left=None, right=None): 5 | self.val = val 6 | self.left = left 7 | self.right = right 8 | 9 | class Solution: 10 | def hasPathSum(self, root: Optional[TreeNode], targetSum: int) -> bool: 11 | if root is None: 12 | return False 13 | 14 | self.left = root.left 15 | self.right = root.right 16 | self.val = root.val 17 | 18 | if not self.left and not self.right: 19 | return targetSum - self.val == 0 20 | 21 | targetSum -= self.val 22 | 23 | return self.hasPathSum(root.left, targetSum) or self.hasPathSum(root.right, targetSum) 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /problems/solutions/0141-linked-list-cycle/en/description.md: -------------------------------------------------------------------------------- 1 | # 141. Linked List Cycle (Easy) 2 | 3 | Given `head`, the head of a linked list, determine if the linked list has a 4 | cycle in it. 5 | 6 | There is a cycle in a linked list if there is some node in the list that can 7 | be reached again by continuously following the `next` pointer. Internally, 8 | `pos` is used to denote the index of the node that tail's `next` pointer is 9 | connected to. **Note that `pos` is not passed as a parameter**. 10 | 11 | Return `true` _if there is a cycle in the linked list_. Otherwise, return 12 | `false`. 13 | 14 | ## Example 1: 15 | 16 | ![](https://assets.leetcode.com/uploads/2018/12/07/circularlinkedlist.png) 17 | 18 | 19 | 20 | Input: head = [3,2,0,-4], pos = 1 21 | Output: true 22 | Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed). 23 | 24 | 25 | ## Example 2: 26 | 27 | ![](https://assets.leetcode.com/uploads/2018/12/07/circularlinkedlist_test2.png) 28 | 29 | 30 | 31 | Input: head = [1,2], pos = 0 32 | Output: true 33 | Explanation: There is a cycle in the linked list, where the tail connects to the 0th node. 34 | 35 | 36 | ## Example 3: 37 | 38 | ![](https://assets.leetcode.com/uploads/2018/12/07/circularlinkedlist_test3.png) 39 | 40 | 41 | 42 | Input: head = [1], pos = -1 43 | Output: false 44 | Explanation: There is no cycle in the linked list. 45 | 46 | 47 | ## Constraints 48 | 49 | * The number of the nodes in the list is in the range `[0, 104]`. 50 | * `-105 <= Node.val <= 105` 51 | * `pos` is `-1` or a **valid index** in the linked-list. 52 | 53 | **Follow up:** Can you solve it using `O(1)` (i.e. constant) memory? 54 | -------------------------------------------------------------------------------- /problems/solutions/0141-linked-list-cycle/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 141. Linked List Cycle (Easy) 2 | 3 | ## Problem 4 | 5 | Given the `head` of a singly linked list, determine if the list has a cycle in it. Return `True` if there is a cycle; otherwise, return `False`. 6 | 7 | ## Examples 8 | 9 | 1. **Input:** `head = [3,2,0,-4]`, where the tail connects to the node at index `1` 10 | **Output:** `True` 11 | 12 | 2. **Input:** `head = [1,2]`, where the tail connects to the node at index `0` 13 | **Output:** `True` 14 | 15 | 3. **Input:** `head = [1]`, with no cycle 16 | **Output:** `False` 17 | 18 | ## Approach 19 | 20 | Use two pointers (`slow` and `fast`) to detect a cycle (Floyd’s Tortoise and Hare algorithm): 21 | 22 | 1. If `head` is `None` or `head.next` is `None`, immediately return `False` (no cycle possible). 23 | 2. Initialize: 24 | - `slow = head` 25 | - `fast = head.next` 26 | 3. Loop while both `fast` and `fast.next` are not `None`: 27 | - If `slow` is equal to `fast`, a cycle exists; return `True`. 28 | - Advance `slow` by one step: `slow = slow.next` 29 | - Advance `fast` by two steps: `fast = fast.next.next` 30 | 4. If the loop terminates, `fast` has reached the end; return `False` (no cycle). 31 | 32 | ## Complexity Analysis 33 | 34 | - **Time Complexity:** O(n), where n is the number of nodes; each pointer moves at most n steps. 35 | - **Space Complexity:** O(1), only two pointers are used. 36 | -------------------------------------------------------------------------------- /problems/solutions/0141-linked-list-cycle/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 141. Linked List Cycle (Fácil) 2 | 3 | Dada `head ', o chefe de uma lista vinculada, determine se a lista vinculada tem um 4 | ciclo nele. 5 | 6 | Há um ciclo em uma lista vinculada se houver algum nó na lista que possa 7 | Seja alcançado novamente seguindo continuamente o ponteiro `Next '.Internamente, 8 | `pos 'é usado para denotar o índice do nó que o ponteiro` próximo' da cauda é 9 | conectado a.** Observe que `pos 'não é passado como um parâmetro **. 10 | 11 | Retorne `true` _ Se houver um ciclo na lista vinculada_.Caso contrário, retorne 12 | `false`. 13 | 14 | ## Exemplo 1: 15 | 16 | ! [] (https://assets.leetcode.com/uploads/2018/12/07/circularlinkedlist.png) 17 | 18 | 19 | 20 | Entrada: Head = [3,2,0, -4], pos = 1 21 | Saída: true 22 | Explicação: Há um ciclo na lista vinculada, onde a cauda se conecta ao 1º nó (Indexado 0). 23 | 24 | 25 | ## Exemplo 2: 26 | 27 | ! [] (https://assets.leetcode.com/uploads/2018/12/07/circularlinkedlist_test2.png) 28 | 29 | 30 | 31 | Entrada: Head = [1,2], POS = 0 32 | Saída: true 33 | Explicação: Há um ciclo na lista vinculada, onde a cauda se conecta ao 0º nó. 34 | 35 | 36 | ## Exemplo 3: 37 | 38 | ! [] (https://assets.leetcode.com/uploads/2018/12/07/circularlinkedlist_test3.png) 39 | 40 | 41 | 42 | Entrada: Head = [1], POS = -1 43 | Saída: false 44 | Explicação: Não há ciclo na lista vinculada. 45 | 46 | 47 | ## restrições 48 | 49 | * O número de nós na lista está no intervalo `[0, 104]`. 50 | * `-105 <= node.val <= 105` 51 | *`POS` é` -1` ou um índice válido ** na lista vinculada. 52 | 53 | ** Acompanhe: ** Você pode resolvê -lo usando a memória `o (1)` (ou seja, constante)? 54 | -------------------------------------------------------------------------------- /problems/solutions/0141-linked-list-cycle/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 141. Ciclo em Lista Encadeada (Fácil) 2 | 3 | ## Enunciado 4 | 5 | Dado o `head` de uma lista ligada simples, determine se a lista contém um ciclo. Retorne `True` se houver ciclo; caso contrário, retorne `False`. 6 | 7 | ## Exemplos 8 | 9 | 1. **Entrada:** `head = [3,2,0,-4]`, onde o último nó conecta-se ao nó no índice `1` 10 | **Saída:** `True` 11 | 12 | 2. **Entrada:** `head = [1,2]`, onde o último nó conecta-se ao nó no índice `0` 13 | **Saída:** `True` 14 | 15 | 3. **Entrada:** `head = [1]`, sem ciclo 16 | **Saída:** `False` 17 | 18 | ## Abordagem 19 | 20 | Utilizamos dois ponteiros (`lento` e `rapido`) para detectar o ciclo (algoritmo de Floyd, “Tartaruga e Lebre”): 21 | 22 | 1. Se `head` for `None` ou `head.next` for `None`, retorne `False` (impossível ter ciclo). 23 | 2. Inicialize: 24 | - `lento = head` 25 | - `rapido = head.next` 26 | 3. Enquanto `rapido` e `rapido.next` não forem `None`: 27 | - Se `lento` for igual a `rapido`, há ciclo; retorne `True`. 28 | - Avance `lento` em um passo: `lento = lento.next` 29 | - Avance `rapido` em dois passos: `rapido = rapido.next.next` 30 | 4. Se o loop terminar, `rapido` atingiu o fim; retorne `False` (sem ciclo). 31 | 32 | ## Análise de Complexidade 33 | 34 | - **Complexidade de Tempo:** O(n), onde n é o número de nós; cada ponteiro avança no máximo n passos. 35 | - **Complexidade de Espaço:** O(1), pois usamos apenas dois ponteiros auxiliares. 36 | -------------------------------------------------------------------------------- /problems/solutions/0141-linked-list-cycle/solution.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | class ListNode: 4 | def __init__(self, x): 5 | self.val = x 6 | self.next = None 7 | 8 | class Solution: 9 | def hasCycle(self, head: Optional[ListNode]) -> bool: 10 | if not head or not head.next: 11 | return False 12 | 13 | fast = head.next 14 | slow = head 15 | 16 | while fast and fast.next: 17 | if slow == fast: 18 | return True 19 | slow = slow.next 20 | fast = fast.next.next 21 | -------------------------------------------------------------------------------- /problems/solutions/0148-sort-list/en/description.md: -------------------------------------------------------------------------------- 1 | # 148. Sort List (Medium) 2 | 3 | Given the `head` of a linked list, return _the list after sorting it 4 | in **ascending order**_. 5 | 6 | ## Example 1: 7 | 8 | ![](https://assets.leetcode.com/uploads/2020/09/14/sort_list_1.jpg) 9 | 10 | Input: head = [4,2,1,3] 11 | Output: [1,2,3,4] 12 | 13 | ## Example 2: 14 | 15 | ![](https://assets.leetcode.com/uploads/2020/09/14/sort_list_2.jpg) 16 | 17 | Input: head = [-1,5,3,4,0] 18 | Output: [-1,0,3,4,5] 19 | 20 | ## Example 3: 21 | 22 | Input: head = [] 23 | Output: [] 24 | 25 | ## Constraints 26 | 27 | - The number of nodes in the list is in the range `[0, 5 * 104]`. 28 | - `-105 <= Node.val <= 105` 29 | 30 | **Follow up:** Can you sort the linked list in `O(n logn)` time and `O(1)` 31 | memory (i.e. constant space)? 32 | -------------------------------------------------------------------------------- /problems/solutions/0148-sort-list/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 148. Sort List - Solution Explanation 2 | 3 | ## Approach: Merge Sort for Linked Lists 4 | 5 | This solution implements the Merge Sort algorithm to sort a linked list. Merge Sort is particularly suitable for linked lists because it can be implemented with O(1) space complexity (not counting the recursive call stack). 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. **Base Case**: If the list is empty or has only one node, it's already sorted. 10 | 11 | 2. **Division**: We split the list into two halves: 12 | 13 | - We find the middle of the list using the "fast and slow runner" technique. 14 | - We divide the list into two separate lists. 15 | 16 | 3. **Recursion**: We recursively apply the same sorting process to both halves. 17 | 18 | 4. **Combination**: We merge the two sorted halves into a single sorted list. 19 | 20 | ## Helper Functions: 21 | 22 | 1. **`find_middle(head)`**: Finds the middle node of the list. 23 | 24 | - Uses two pointers: `slow` and `fast`. 25 | - `fast` moves twice as fast as `slow`. 26 | - When `fast` reaches the end, `slow` is at the middle. 27 | 28 | 2. **`merge(l1, l2)`**: Combines two sorted lists into a single sorted list. 29 | - Uses a `dummy` node to simplify head manipulation. 30 | - Compares node values and connects them in ascending order. 31 | - Handles any remaining nodes after one list has been fully traversed. 32 | 33 | ## Step-by-Step Example: 34 | 35 | For the list `4 -> 2 -> 1 -> 3`: 36 | 37 | 1. **Division**: 38 | 39 | - Middle: node with value 2 40 | - Left list: `4 -> 2` 41 | - Right list: `1 -> 3` 42 | 43 | 2. **Recursion on left list** (`4 -> 2`): 44 | 45 | - Division: Middle is node with value 4 46 | - Left list: `4` 47 | - Right list: `2` 48 | - Recursive sorting: `2 -> 4` 49 | 50 | 3. **Recursion on right list** (`1 -> 3`): 51 | 52 | - Division: Middle is node with value 1 53 | - Left list: `1` 54 | - Right list: `3` 55 | - Recursive sorting: `1 -> 3` 56 | 57 | 4. **Final combination**: 58 | - Merging `2 -> 4` and `1 -> 3` 59 | - Result: `1 -> 2 -> 3 -> 4` 60 | -------------------------------------------------------------------------------- /problems/solutions/0148-sort-list/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 148. Ordenar Lista (Médio) 2 | 3 | Dado o `head` de uma lista ligada, retorne **a lista após ordená-la em ordem crescente**. 4 | 5 | ## Exemplo 1: 6 | 7 | ![](https://assets.leetcode.com/uploads/2020/09/14/sort_list_1.jpg) 8 | 9 | Entrada: head = [4,2,1,3] 10 | Saída: [1,2,3,4] 11 | 12 | ## Exemplo 2: 13 | 14 | ![](https://assets.leetcode.com/uploads/2020/09/14/sort_list_2.jpg) 15 | 16 | Entrada: head = [-1,5,3,4,0] 17 | Saída: [-1,0,3,4,5] 18 | 19 | ## Exemplo 3: 20 | 21 | Entrada: head = [] 22 | Saída: [] 23 | 24 | ## Restrições 25 | 26 | - O número de nós na lista está no intervalo `[0, 5 * 10⁴]`. 27 | - `-10⁵ <= Node.val <= 10⁵` 28 | 29 | **Desafio:** Você consegue ordenar a lista ligada em tempo `O(n logn)` e **memória constante** (ou seja, espaço `O(1)`)? 30 | -------------------------------------------------------------------------------- /problems/solutions/0148-sort-list/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 148. Sort List - Explicação da Solução 2 | 3 | ## Abordagem: Merge Sort para Listas Encadeadas 4 | 5 | Esta solução implementa o algoritmo de Merge Sort para ordenar uma lista encadeada. Merge Sort é particularmente adequado para listas encadeadas porque pode ser implementado com complexidade de espaço O(1) (sem contar a pilha de chamadas recursivas). 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. **Caso Base**: Se a lista estiver vazia ou tiver apenas um nó, está automaticamente ordenada. 10 | 11 | 2. **Divisão**: Dividimos a lista em duas metades: 12 | 13 | - Encontramos o meio da lista usando a técnica do "corredor rápido e lento". 14 | - Dividimos a lista em duas listas separadas. 15 | 16 | 3. **Recursão**: Aplicamos recursivamente o mesmo processo de ordenação em ambas as metades. 17 | 18 | 4. **Combinação**: Mesclamos as duas metades ordenadas em uma única lista ordenada. 19 | 20 | ## Funções Auxiliares: 21 | 22 | 1. **`find_middle(head)`**: Encontra o nó do meio da lista. 23 | 24 | - Usa dois ponteiros: `slow` e `fast`. 25 | - `fast` se move duas vezes mais rápido que `slow`. 26 | - Quando `fast` alcança o fim, `slow` está no meio. 27 | 28 | 2. **`merge(l1, l2)`**: Combina duas listas ordenadas em uma única lista ordenada. 29 | - Usa um nó `dummy` para simplificar a manipulação da cabeça da lista. 30 | - Compara os valores dos nós e os conecta em ordem crescente. 31 | - Lida com quaisquer nós restantes após uma das listas ter sido totalmente percorrida. 32 | 33 | ## Exemplo Passo a Passo: 34 | 35 | Para a lista `4 -> 2 -> 1 -> 3`: 36 | 37 | 1. **Divisão**: 38 | 39 | - Meio: nó com valor 2 40 | - Lista esquerda: `4 -> 2` 41 | - Lista direita: `1 -> 3` 42 | 43 | 2. **Recursão na lista esquerda** (`4 -> 2`): 44 | 45 | - Divisão: Meio é o nó com valor 4 46 | - Lista esquerda: `4` 47 | - Lista direita: `2` 48 | - Ordenação recursiva: `2 -> 4` 49 | 50 | 3. **Recursão na lista direita** (`1 -> 3`): 51 | 52 | - Divisão: Meio é o nó com valor 1 53 | - Lista esquerda: `1` 54 | - Lista direita: `3` 55 | - Ordenação recursiva: `1 -> 3` 56 | 57 | 4. **Combinação final**: 58 | - Mesclagem de `2 -> 4` e `1 -> 3` 59 | - Resultado: `1 -> 2 -> 3 -> 4` 60 | -------------------------------------------------------------------------------- /problems/solutions/0148-sort-list/solution.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | class ListNode(object): 4 | def __init__(self, val=0, next=None): 5 | self.val = val 6 | self.next = next 7 | 8 | class Solution: 9 | def sortList(self, head: Optional[ListNode]) -> Optional[ListNode]: 10 | # Base case: if the list is empty or has only one node, it's already sorted 11 | if not head or not head.next: 12 | return head 13 | 14 | # Helper function to find the middle of the linked list 15 | def find_middle(head: ListNode) -> ListNode: 16 | slow = head 17 | fast = head.next 18 | 19 | # Move 'fast' two steps and 'slow' one step to find the middle 20 | while fast and fast.next: 21 | slow = slow.next 22 | fast = fast.next.next 23 | return slow # 'slow' will be at the middle 24 | 25 | # Helper function to merge two sorted linked lists 26 | def merge(l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]: 27 | dummy = ListNode() 28 | tail = dummy 29 | 30 | # Merge nodes in sorted order 31 | while l1 and l2: 32 | if l1.val < l2.val: 33 | tail.next = l1 34 | l1 = l1.next 35 | else: 36 | tail.next = l2 37 | l2 = l2.next 38 | tail = tail.next 39 | 40 | # Append any remaining nodes 41 | tail.next = l1 or l2 42 | return dummy.next # Return the head of the merged list 43 | 44 | # Split the list into two halves 45 | middle = find_middle(head) 46 | right_head = middle.next 47 | middle.next = None # Break the list into two halves 48 | 49 | # Recursively sort both halves 50 | left = self.sortList(head) 51 | right = self.sortList(right_head) 52 | 53 | # Merge the sorted halves 54 | return merge(left, right) 55 | -------------------------------------------------------------------------------- /problems/solutions/0148-sort-list/solution.ts: -------------------------------------------------------------------------------- 1 | class ListNode { 2 | val: number; 3 | next: ListNode | null; 4 | constructor(val?: number, next?: ListNode | null) { 5 | this.val = val === undefined ? 0 : val; 6 | this.next = next === undefined ? null : next; 7 | } 8 | } 9 | 10 | function sortList(head: ListNode | null): ListNode | null { 11 | // Base case: if the list is empty or has only one node, it's already sorted 12 | if (!head || !head.next) return head; 13 | 14 | // Helper function to find the middle node of the linked list 15 | const findMiddle = (head: ListNode): ListNode => { 16 | let slow: ListNode = head; 17 | let fast: ListNode | null = head.next; 18 | 19 | // Move 'fast' two steps and 'slow' one step to find the middle 20 | while (fast && fast.next) { 21 | slow = slow.next!; 22 | fast = fast.next.next; 23 | } 24 | return slow; // 'slow' will be at the middle 25 | }; 26 | 27 | // Helper function to merge two sorted linked lists 28 | const mergeTwoLists = ( 29 | l1: ListNode | null, 30 | l2: ListNode | null 31 | ): ListNode | null => { 32 | const dummy = new ListNode(); // Dummy node to simplify merging 33 | let tail = dummy; 34 | 35 | // Merge nodes in sorted order 36 | while (l1 && l2) { 37 | if (l1.val < l2.val) { 38 | tail.next = l1; 39 | l1 = l1.next; 40 | } else { 41 | tail.next = l2; 42 | l2 = l2.next; 43 | } 44 | tail = tail.next; 45 | } 46 | 47 | // Append any remaining nodes 48 | tail.next = l1 || l2; 49 | return dummy.next; // Return the head of the merged list 50 | }; 51 | 52 | // Split the list into two halves 53 | const middle = findMiddle(head); 54 | const nextToMiddle = middle.next; 55 | middle.next = null; // Break the list 56 | 57 | // Recursively sort both halves 58 | const left = sortList(head); 59 | const right = sortList(nextToMiddle); 60 | 61 | // Merge the sorted halves 62 | return mergeTwoLists(left, right); 63 | } 64 | -------------------------------------------------------------------------------- /problems/solutions/0191-number-of-1-bits/en/description.md: -------------------------------------------------------------------------------- 1 | # 191. Number of 1 Bits (Easy) 2 | 3 | Given a positive integer `n`, write a function that returns the number of set 4 | bits in its binary representation (also known as the [Hamming 5 | weight](http://en.wikipedia.org/wiki/Hamming_weight)). 6 | 7 | ## Example 1: 8 | 9 | Input: n = 11 10 | 11 | Output: 3 12 | 13 | Explanation: 14 | 15 | The input binary string **1011** has a total of three set bits. 16 | 17 | ## Example 2: 18 | 19 | Input: n = 128 20 | 21 | Output: 1 22 | 23 | Explanation: 24 | 25 | The input binary string **10000000** has a total of one set bit. 26 | 27 | ## Example 3: 28 | 29 | Input: n = 2147483645 30 | 31 | Output: 30 32 | 33 | Explanation: 34 | 35 | The input binary string **1111111111111111111111111111101** has a total of 36 | thirty set bits. 37 | 38 | ## Constraints 39 | 40 | * `1 <= n <= 231 - 1` 41 | 42 | **Follow up:** If this function is called many times, how would you optimize 43 | it? 44 | -------------------------------------------------------------------------------- /problems/solutions/0191-number-of-1-bits/en/explanation.md: -------------------------------------------------------------------------------- 1 | # How to solve the problem #191 Number of 1 Bits 2 | 3 | At first, you need to think on the steps. 4 | You might thinking "right, but how do I do it?" 5 | Well, each person have a way to do this, but I believe that the best one is comment STEP BY STEP what you need to do based on description of the problem, e.g.: 6 | 7 | ```typescript 8 | // 1. Transform in Binary 9 | // 2. Take the quantity binary 1 10 | ``` 11 | 12 | Nice! Now let's start thinking about the code. 13 | 14 | ### 1. Create a variable to convert the number to binary and split the zeros in parameter 'n': 15 | 16 | ```typescript 17 | var number: string = (n >>> 0).toString(2).replaceAll("0", ""); 18 | ``` 19 | 20 | ### 2. Convert the sequence of characteres to number: 21 | 22 | ```typescript 23 | var stringToNumber: number = parseInt(number); 24 | ``` 25 | 26 | ### 3. Do a loop and increments de local variable 'i' into variable 'stringToNumber': 27 | 28 | ```typescript 29 | for (let i = 0; i <= number.length; i++) { 30 | stringToNumber = i; 31 | } 32 | ``` 33 | 34 | ### 4. Return the value of stringToNumber: 35 | 36 | ```typescript 37 | return stringToNumber; 38 | ``` 39 | 40 | :D 41 | -------------------------------------------------------------------------------- /problems/solutions/0191-number-of-1-bits/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 191. Number of 1 Bits (Fácil) 2 | 3 | Dado um número inteiro positivo `n`, escreva uma função que retorne o número de conjunto 4 | bits em sua representação binária (também conhecida como [hamming 5 | Peso] (http://en.wikipedia.org/wiki/hamming_weight)). 6 | 7 | ## Exemplo 1: 8 | 9 | Entrada: n = 11 10 | 11 | Saída: 3 12 | 13 | Explicação: 14 | 15 | A sequência binária de entrada ** 1011 ** tem um total de três bits. 16 | 17 | ## Exemplo 2: 18 | 19 | Entrada: n = 128 20 | 21 | Saída: 1 22 | 23 | Explicação: 24 | 25 | A sequência binária de entrada ** 10000000 ** tem um total de um bit de conjunto. 26 | 27 | ## Exemplo 3: 28 | 29 | Entrada: n = 2147483645 30 | 31 | Saída: 30 32 | 33 | Explicação: 34 | 35 | A sequência binária de entrada ** 1111111111111111111111111111101 ** tem um total de 36 | trinta bits. 37 | 38 | ## restrições 39 | 40 | * `1 <= n <= 231 - 1` 41 | 42 | ** acompanhe: ** Se essa função for chamada muitas vezes, como você otimizaria 43 | isto? 44 | -------------------------------------------------------------------------------- /problems/solutions/0191-number-of-1-bits/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # Como resolver o problema #191 Número de Bits 1 2 | 3 | Primeiramente, você precisa pensar nos passos. 4 | Você pode estar pensando "certo, mas como faço isso?" 5 | Bem, cada pessoa tem uma maneira de fazer isso, mas acredito que a melhor é comentar PASSO A PASSO o que você precisa fazer com base na descrição do problema, por exemplo: 6 | 7 | ```typescript 8 | // 1. Transformar em Binário 9 | // 2. Obter a quantidade binária 1 10 | ``` 11 | 12 | Legal! Agora vamos começar a pensar no código. 13 | 14 | ### 1. Crie uma variável para converter o número para binário e separar os zeros no parâmetro 'n': 15 | 16 | ```typescript 17 | var number: string = (n >>> 0).toString(2).replaceAll("0", ""); 18 | ``` 19 | 20 | ### 2. Converta a sequência de caracteres em um número: 21 | 22 | ```typescript 23 | var stringToNumber: number = parseInt(number); 24 | ``` 25 | 26 | ### 3. Execute um loop e incremente a variável local 'i' na variável 'stringToNumber': 27 | 28 | ```typescript 29 | for (let i = 0; i <= number.length; i++) { 30 | stringToNumber = i; 31 | } 32 | ``` 33 | 34 | ### 4. Retorne o valor de stringToNumber: 35 | 36 | ```typescript 37 | return stringToNumber; 38 | ``` 39 | 40 | :D 41 | -------------------------------------------------------------------------------- /problems/solutions/0191-number-of-1-bits/solution.ts: -------------------------------------------------------------------------------- 1 | function hammingWeight(n: number): number { 2 | var number: string = (n >>> 0).toString(2).replaceAll('0', ''); // convert to binary 3 | 4 | var stringToNumber: number = parseInt(number); // convert to number 5 | 6 | for (let i = 0; i <= number.length; i++) { 7 | stringToNumber = i; // attribute counter to variable that will be returned 8 | } 9 | 10 | return stringToNumber; 11 | } 12 | 13 | // 1. Transformar em binário 14 | // 2. Pegar quantidade de 1 no binário 15 | -------------------------------------------------------------------------------- /problems/solutions/0206-reverse-linked-list/en/description.md: -------------------------------------------------------------------------------- 1 | # 206. Reverse Linked List (Easy) 2 | 3 | Given the `head` of a singly linked list, reverse the list, and return _the 4 | reversed list_. 5 | 6 | ## Example 1: 7 | 8 | ![](https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg) 9 | 10 | 11 | 12 | Input: head = [1,2,3,4,5] 13 | Output: [5,4,3,2,1] 14 | 15 | 16 | ## Example 2: 17 | 18 | ![](https://assets.leetcode.com/uploads/2021/02/19/rev1ex2.jpg) 19 | 20 | 21 | 22 | Input: head = [1,2] 23 | Output: [2,1] 24 | 25 | 26 | ## Example 3: 27 | 28 | 29 | 30 | Input: head = [] 31 | Output: [] 32 | 33 | 34 | ## Constraints 35 | 36 | * The number of nodes in the list is the range `[0, 5000]`. 37 | * `-5000 <= Node.val <= 5000` 38 | 39 | **Follow up:** A linked list can be reversed either iteratively or 40 | recursively. Could you implement both? 41 | -------------------------------------------------------------------------------- /problems/solutions/0206-reverse-linked-list/en/explanation.md: -------------------------------------------------------------------------------- 1 | ## Problem 2 | Given the `head` of a singly linked list, reverse the list and return the new head of the reversed list. 3 | 4 | ## Examples 5 | 1. **Input:** `head = [1,2,3,4,5]` 6 | **Output:** `[5,4,3,2,1]` 7 | 8 | 2. **Input:** `head = [1,2]` 9 | **Output:** `[2,1]` 10 | 11 | 3. **Input:** `head = []` 12 | **Output:** `[]` 13 | 14 | ## Approach 15 | We use three pointers to reverse the list in-place: 16 | 17 | 1. Initialize: 18 | - `prev = None` 19 | - `curr = head` 20 | 2. Iterate while `curr` is not `None`: 21 | - `nextTemp = curr.next` # Save next node 22 | - `curr.next = prev` # Reverse pointer 23 | - `prev = curr` # Move prev forward 24 | - `curr = nextTemp` # Move curr forward 25 | 3. When the loop ends, `prev` points to the new head of the reversed list. Return `prev`. 26 | 27 | ## Step-by-Step Example 28 | For the list `1 → 2 → 3`: 29 | 30 | ```plaintext 31 | Initial: prev=None, curr=Node(1) 32 | 33 | Iteration 1: 34 | nextTemp = Node(2) 35 | curr.next = None # 1 → None 36 | prev = Node(1) 37 | curr = Node(2) 38 | 39 | Iteration 2: 40 | nextTemp = Node(3) 41 | curr.next = Node(1) # 2 → 1 → None 42 | prev = Node(2) 43 | curr = Node(3) 44 | 45 | Iteration 3: 46 | nextTemp = None 47 | curr.next = Node(2) # 3 → 2 → 1 → None 48 | prev = Node(3) 49 | curr = None 50 | 51 | Loop ends, return prev (Node(3)), list is now 3 → 2 → 1 52 | -------------------------------------------------------------------------------- /problems/solutions/0206-reverse-linked-list/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 206. Reverse Linked List (Fácil) 2 | 3 | Dada a `cabeça 'de uma lista individual, reverte a lista e retornar 4 | Lista revertida_. 5 | 6 | ## Exemplo 1: 7 | 8 | ! [] (https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg) 9 | 10 | 11 | 12 | Entrada: Head = [1,2,3,4,5] 13 | Saída: [5,4,3,2,1] 14 | 15 | 16 | ## Exemplo 2: 17 | 18 | ! [] (https://assets.leetcode.com/uploads/2021/02/19/rev1ex2.jpg) 19 | 20 | 21 | 22 | Entrada: Head = [1,2] 23 | Saída: [2,1] 24 | 25 | 26 | ## Exemplo 3: 27 | 28 | 29 | 30 | Entrada: Head = [] 31 | Saída: [] 32 | 33 | 34 | ## restrições 35 | 36 | * O número de nós na lista é o intervalo `[0, 5000]`. 37 | * `-5000 <= node.val <= 5000` 38 | 39 | ** acompanhamento: ** Uma lista vinculada pode ser revertida de maneira itera ou 40 | recursivamente.Você poderia implementar os dois? 41 | -------------------------------------------------------------------------------- /problems/solutions/0206-reverse-linked-list/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | ## Enunciado 2 | Dado o `head` de uma lista ligada simples, inverta a lista e retorne o novo `head` da lista invertida. 3 | 4 | ## Exemplos 5 | 1. **Entrada:** `head = [1,2,3,4,5]` 6 | **Saída:** `[5,4,3,2,1]` 7 | 8 | 2. **Entrada:** `head = [1,2]` 9 | **Saída:** `[2,1]` 10 | 11 | 3. **Entrada:** `head = []` 12 | **Saída:** `[]` 13 | 14 | ## Abordagem 15 | Utilizamos três ponteiros para inverter a lista in-place: 16 | 17 | 1. Inicialize: 18 | - `prev = None` 19 | - `curr = head` 20 | 2. Enquanto `curr` for diferente de `None`: 21 | - `nextTemp = curr.next` # Armazena o próximo nó 22 | - `curr.next = prev` # Inverte o ponteiro 23 | - `prev = curr` # Avança `prev` 24 | - `curr = nextTemp` # Avança `curr` 25 | 3. Ao final do loop, `prev` aponta para o novo head. Retorne `prev`. 26 | 27 | ## Exemplo Passo a Passo 28 | Para a lista `1 → 2 → 3`: 29 | 30 | Inicial: prev=None, curr=Node(1) 31 | 32 | Iteração 1: 33 | nextTemp = Node(2) 34 | curr.next = None # 1 → None 35 | prev = Node(1) 36 | curr = Node(2) 37 | 38 | Iteração 2: 39 | nextTemp = Node(3) 40 | curr.next = Node(1) # 2 → 1 → None 41 | prev = Node(2) 42 | curr = Node(3) 43 | 44 | Iteração 3: 45 | nextTemp = None 46 | curr.next = Node(2) # 3 → 2 → 1 → None 47 | prev = Node(3) 48 | curr = None 49 | 50 | Loop termina, retorna prev (Node(3)), resultando em 3 → 2 → 1 51 | 52 | ## Análise de Complexidade 53 | Complexidade de Tempo: O(n), onde n é o número de nós; cada nó é processado uma vez. 54 | 55 | Complexidade de Espaço: O(1), pois usamos apenas ponteiros auxiliares. -------------------------------------------------------------------------------- /problems/solutions/0206-reverse-linked-list/solution.py: -------------------------------------------------------------------------------- 1 | from optparse import Optional 2 | 3 | class ListNode: 4 | def __init__(self, val=0, next=None): 5 | self.val = val 6 | self.next = next 7 | 8 | class Solution: 9 | def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: 10 | prev = None 11 | curr = head 12 | 13 | while curr: 14 | nextPrev = curr.next 15 | curr.next = prev 16 | prev = curr 17 | curr = nextPrev 18 | return prev -------------------------------------------------------------------------------- /problems/solutions/0219-contains-duplicate-ii/en/description.md: -------------------------------------------------------------------------------- 1 | # 219. Contains Duplicate II (Easy) 2 | 3 | Given an integer array `nums` and an integer `k`, return `true` _if there are 4 | two**distinct indices** _`i` _and_`j` _in the array such that_`nums[i] == 5 | nums[j]`_and_`abs(i - j) <= k`. 6 | 7 | ## Example 1: 8 | 9 | 10 | 11 | Input: nums = [1,2,3,1], k = 3 12 | Output: true 13 | 14 | 15 | ## Example 2: 16 | 17 | 18 | 19 | Input: nums = [1,0,1,1], k = 1 20 | Output: true 21 | 22 | 23 | ## Example 3: 24 | 25 | 26 | 27 | Input: nums = [1,2,3,1,2,3], k = 2 28 | Output: false 29 | 30 | 31 | ## Constraints 32 | 33 | * `1 <= nums.length <= 105` 34 | * `-109 <= nums[i] <= 109` 35 | * `0 <= k <= 105` 36 | -------------------------------------------------------------------------------- /problems/solutions/0219-contains-duplicate-ii/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 219. Contains Duplicate II - Solution Explanation 2 | 3 | ## Approach: Using Hash Map (Dictionary) 4 | 5 | The solution uses a hash map to keep track of the last seen index of each number, allowing us to efficiently check for duplicates within the specified distance k. 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. We create an empty hash map `numToIndex` to store the last seen index of each number. 10 | 2. We iterate through the array with a loop. 11 | 3. For each number: 12 | - If we've seen this number before (it exists in the map): 13 | - Calculate the distance between current index and last seen index 14 | - If the distance is less than or equal to k, we found a valid duplicate 15 | - Otherwise, update the last seen index to current index 16 | - If we haven't seen this number, add it to the map with current index 17 | 18 | ## Step-by-Step Example: 19 | 20 | Using the example: `nums = [1,2,3,1]`, `k = 3` 21 | 22 | 1. Initialize `numToIndex = {}` 23 | 2. Iteration 1 (i=0): 24 | - `num = 1` 25 | - Not in map, add `numToIndex[1] = 0` 26 | 3. Iteration 2 (i=1): 27 | - `num = 2` 28 | - Not in map, add `numToIndex[2] = 1` 29 | 4. Iteration 3 (i=2): 30 | - `num = 3` 31 | - Not in map, add `numToIndex[3] = 2` 32 | 5. Iteration 4 (i=3): 33 | - `num = 1` 34 | - Found in map at index 0 35 | - Distance = 3 - 0 = 3 ≤ k 36 | - Return true 37 | 38 | ## Time and Space Complexity: 39 | 40 | - Time Complexity: O(n) - We make a single pass through the array 41 | - Space Complexity: O(min(n,k)) - In worst case, we store at most k elements in the map 42 | -------------------------------------------------------------------------------- /problems/solutions/0219-contains-duplicate-ii/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 219. Contains Duplicate II (Fácil) 2 | 3 | Dada uma matriz inteira `nums` e um número inteiro` k`, return `true` _ se houver 4 | Dois ** índices distintos ** _`i` _and_`j` _ na matriz tais que_`nums [i] == 5 | Nums [j] `_and_`abs (i - j) <= k`. 6 | 7 | ## Exemplo 1: 8 | 9 | 10 | 11 | Entrada: nums = [1,2,3,1], k = 3 12 | Saída: true 13 | 14 | 15 | ## Exemplo 2: 16 | 17 | 18 | 19 | Entrada: nums = [1,0,1,1], k = 1 20 | Saída: true 21 | 22 | 23 | ## Exemplo 3: 24 | 25 | 26 | 27 | Entrada: nums = [1,2,3,1,2,3], k = 2 28 | Saída: false 29 | 30 | 31 | ## restrições 32 | 33 | * `1 <= nums.Length <= 105` 34 | * `-109 <= nums [i] <= 109` 35 | * `0 <= k <= 105` 36 | -------------------------------------------------------------------------------- /problems/solutions/0219-contains-duplicate-ii/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 219. Contém Duplicata II - Explicação da Solução 2 | 3 | ## Abordagem: Usando Mapa Hash (Dicionário) 4 | 5 | A solução utiliza um mapa hash para manter o controle do último índice visto de cada número, permitindo verificar eficientemente duplicatas dentro da distância k especificada. 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. Criamos um mapa hash vazio `numToIndex` para armazenar o último índice visto de cada número. 10 | 2. Iteramos pelo array com um loop. 11 | 3. Para cada número: 12 | - Se já vimos este número antes (ele existe no mapa): 13 | - Calculamos a distância entre o índice atual e o último índice visto 14 | - Se a distância for menor ou igual a k, encontramos uma duplicata válida 15 | - Caso contrário, atualizamos o último índice visto para o índice atual 16 | - Se não vimos este número, adicionamos ao mapa com o índice atual 17 | 18 | ## Exemplo Passo a Passo: 19 | 20 | Usando o exemplo: `nums = [1,2,3,1]`, `k = 3` 21 | 22 | 1. Inicializar `numToIndex = {}` 23 | 2. Iteração 1 (i=0): 24 | - `num = 1` 25 | - Não está no mapa, adicionar `numToIndex[1] = 0` 26 | 3. Iteração 2 (i=1): 27 | - `num = 2` 28 | - Não está no mapa, adicionar `numToIndex[2] = 1` 29 | 4. Iteração 3 (i=2): 30 | - `num = 3` 31 | - Não está no mapa, adicionar `numToIndex[3] = 2` 32 | 5. Iteração 4 (i=3): 33 | - `num = 1` 34 | - Encontrado no mapa no índice 0 35 | - Distância = 3 - 0 = 3 ≤ k 36 | - Retornar true 37 | 38 | ## Complexidade de Tempo e Espaço: 39 | 40 | - Complexidade de Tempo: O(n) - Fazemos uma única passagem pelo array 41 | - Complexidade de Espaço: O(min(n,k)) - No pior caso, armazenamos no máximo k elementos no mapa -------------------------------------------------------------------------------- /problems/solutions/0219-contains-duplicate-ii/solution.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | class Solution: 4 | def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool: 5 | window = set() 6 | l = 0 7 | 8 | for r in range(len(nums)): 9 | if r - l > k: 10 | window.discard(nums[l]) 11 | l += 1 12 | if nums[r] in window: 13 | return True 14 | window.add(nums[r]) 15 | 16 | return False -------------------------------------------------------------------------------- /problems/solutions/0342-power-of-four/en/description.md: -------------------------------------------------------------------------------- 1 | # 342. Power of Four (Easy) 2 | 3 | Given an integer `n`, return _`true` if it is a power of four. Otherwise, 4 | return `false`_. 5 | 6 | An integer `n` is a power of four, if there exists an integer `x` such that `n 7 | == 4x`. 8 | 9 | ## Example 1: 10 | 11 | 12 | 13 | Input: n = 16 14 | Output: true 15 | 16 | 17 | ## Example 2: 18 | 19 | 20 | 21 | Input: n = 5 22 | Output: false 23 | 24 | 25 | ## Example 3: 26 | 27 | 28 | 29 | Input: n = 1 30 | Output: true 31 | 32 | 33 | ## Constraints 34 | 35 | * `-231 <= n <= 231 - 1` 36 | 37 | **Follow up:** Could you solve it without loops/recursion? 38 | -------------------------------------------------------------------------------- /problems/solutions/0342-power-of-four/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 342. Power of Four - Solution Explanation 2 | 3 | ## Approach: Logarithmic Check with Integer Validation 4 | 5 | This solution checks whether a number is a power of 4 using logarithms and a simple integer verification. The idea is based on the mathematical definition of exponentiation using logarithmic properties. 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. **Initial Check**: 10 | - If `n` is less than or equal to 0, return `false`, since negative numbers and zero cannot be powers of 4. 11 | 12 | 2. **Logarithmic Calculation**: 13 | - Use the change-of-base formula to calculate the logarithm of `n` in base 4: 14 | ``` 15 | log₄(n) = log₁₀(n) / log₁₀(4) 16 | ``` 17 | - This returns a value `x` such that `4^x = n`. 18 | 19 | 3. **Integer Validation**: 20 | - If the result is an integer (`Number.isInteger(value)`), then `n` is an exact power of 4. 21 | - Otherwise, it is not. 22 | 23 | ## Step-by-Step Example: 24 | 25 | ### To check if `n = 16` is a power of 4: 26 | 27 | 1. `n = 16` → greater than 0, continue. 28 | 2. Compute `value = Math.log(16) / Math.log(4)`: 29 | - `Math.log(16) ≈ 2.7726` 30 | - `Math.log(4) ≈ 1.3863` 31 | - `value ≈ 2.7726 / 1.3863 ≈ 2` 32 | 3. `Number.isInteger(2)` returns `true` 33 | 34 | ✅ Final result: `isPowerOfFour(16)` returns `true` because `4² = 16`. 35 | 36 | ## Code Used 37 | 38 | ```ts 39 | function isPowerOfFour(n: number): boolean { 40 | if (n <= 0) return false; 41 | 42 | const value: number = Math.log(n) / Math.log(4); 43 | 44 | return Number.isInteger(value); 45 | } 46 | -------------------------------------------------------------------------------- /problems/solutions/0342-power-of-four/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 342. Power of Four (Fácil) 2 | 3 | Dado um número inteiro `n`, retorne _ `TUE` se for um poder de quatro.De outra forma, 4 | retornar `false`_. 5 | 6 | Um número inteiro `n` é um poder de quatro, se existe um número inteiro` x` tal que `n 7 | == 4x`. 8 | 9 | ## Exemplo 1: 10 | 11 | 12 | 13 | Entrada: n = 16 14 | Saída: true 15 | 16 | 17 | ## Exemplo 2: 18 | 19 | 20 | 21 | Entrada: n = 5 22 | Saída: false 23 | 24 | 25 | ## Exemplo 3: 26 | 27 | 28 | 29 | Entrada: n = 1 30 | Saída: true 31 | 32 | 33 | ## restrições 34 | 35 | * `-231 <= n <= 231 - 1` 36 | 37 | ** Acompanhamento: ** Você poderia resolvê -lo sem loops/recursão? 38 | -------------------------------------------------------------------------------- /problems/solutions/0342-power-of-four/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 342. Power of Four - Explicação da Solução 2 | 3 | ## Abordagem: Logaritmo com Verificação de Inteiro 4 | 5 | Esta solução verifica se um número é uma potência de 4 utilizando logaritmo e uma simples verificação de número inteiro. A ideia é aplicar a definição matemática de potência com base logarítmica. 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. **Verificação Inicial**: 10 | - Se `n` for menor ou igual a 0, retornamos `false`, pois números negativos ou zero não são potências de 4. 11 | 12 | 2. **Cálculo com Logaritmo**: 13 | - Utilizamos a fórmula de mudança de base para calcular o logaritmo de `n` na base 4: 14 | ``` 15 | log₄(n) = log₁₀(n) / log₁₀(4) 16 | ``` 17 | - Essa fórmula retorna o valor `x` tal que `4^x = n`. 18 | 19 | 3. **Verificação de Inteiro**: 20 | - Se o valor calculado for um número inteiro (`Number.isInteger(value)`), então `n` é uma potência exata de 4. 21 | - Caso contrário, não é. 22 | 23 | ## Exemplo Passo a Passo: 24 | 25 | ### Para verificar se `n = 16` é uma potência de 4: 26 | 27 | 1. `n = 16` → é maior que 0, então seguimos. 28 | 2. Calculamos `value = Math.log(16) / Math.log(4)`: 29 | - `Math.log(16) ≈ 2.7726` 30 | - `Math.log(4) ≈ 1.3863` 31 | - `value ≈ 2.7726 / 1.3863 ≈ 2` 32 | 3. `Number.isInteger(2)` retorna `true` 33 | 34 | ✅ Resultado final: `isPowerOfFour(16)` retorna `true` porque `4² = 16`. 35 | 36 | ## Código Utilizado 37 | 38 | ```ts 39 | function isPowerOfFour(n: number): boolean { 40 | if (n <= 0) return false; 41 | 42 | const value: number = Math.log(n) / Math.log(4); 43 | 44 | return Number.isInteger(value); 45 | } 46 | -------------------------------------------------------------------------------- /problems/solutions/0342-power-of-four/solution.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | class Solution: 4 | def isPowerOfFour(self, n: int) -> bool: 5 | 6 | if n <= 0: 7 | return False 8 | 9 | val = math.log(n) / math.log(4) 10 | 11 | isBoolean = True 12 | 13 | if val == math.floor(val): 14 | isBoolean = True 15 | else: 16 | isBoolean = False 17 | 18 | return isBoolean -------------------------------------------------------------------------------- /problems/solutions/0342-power-of-four/solution.ts: -------------------------------------------------------------------------------- 1 | function isPowerOfFour(n: number): boolean { 2 | if (n <= 0) return false; 3 | 4 | var value: number = Math.log(n) / Math.log(4); 5 | 6 | return Number.isInteger(value); 7 | } 8 | -------------------------------------------------------------------------------- /problems/solutions/0345-reverse-vowels-of-a-string/en/description.md: -------------------------------------------------------------------------------- 1 | # 345. Reverse Vowels of a String (Easy) 2 | 3 | Given a string `s`, reverse only all the vowels in the string and return it. 4 | 5 | The vowels are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`, and they can appear in 6 | both lower and upper cases, more than once. 7 | 8 | ## Example 1: 9 | 10 | Input: s = "IceCreAm" 11 | 12 | Output: "AceCreIm" 13 | 14 | Explanation: 15 | 16 | The vowels in `s` are `['I', 'e', 'e', 'A']`. On reversing the vowels, s 17 | becomes `"AceCreIm"`. 18 | 19 | ## Example 2: 20 | 21 | Input: s = "leetcode" 22 | 23 | Output: "leotcede" 24 | 25 | ## Constraints 26 | 27 | - `1 <= s.length <= 3 * 105` 28 | - `s` consist of **printable ASCII** characters. 29 | -------------------------------------------------------------------------------- /problems/solutions/0345-reverse-vowels-of-a-string/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 345. Reverse Vowels of a String - Solution Explanation 2 | 3 | ## Approach: Collection and Substitution of Vowels 4 | 5 | This solution reverses only the vowels in a string while keeping all other characters in their original positions. The approach is done in two steps: first we collect all vowels, then we substitute them in reverse order. 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. We convert the input string into an array of characters to make modifications easier. 10 | 2. We define which characters are vowels (a, e, i, o, u - both uppercase and lowercase). 11 | 3. We iterate through the string and collect all vowels found in a separate array. 12 | 4. We iterate through the original string again: 13 | - When we find a vowel, we replace it with the last collected vowel that hasn't been used yet. 14 | - We decrement the index to point to the next vowel to be used in substitution. 15 | 16 | ## Step-by-Step Example: 17 | 18 | Using the example: `s = "hello"` 19 | 20 | 1. Initialization: 21 | 22 | - `stringArray = ['h', 'e', 'l', 'l', 'o']` 23 | - `vowels = ['a', 'e', 'i', 'o', 'u']` 24 | 25 | 2. Collect vowels: 26 | 27 | - We iterate through `stringArray` and identify 'e' and 'o' as vowels 28 | - `vowelsInString = ['e', 'o']` 29 | 30 | 3. Substitute vowels in reverse order: 31 | 32 | - `vowelIndex = 1` (last index of `vowelsInString`) 33 | - First vowel found: 'e' at position 1 34 | - We replace it with `vowelsInString[1]`, which is 'o' 35 | - We decrement `vowelIndex` to 0 36 | - Second vowel found: 'o' at position 4 37 | - We replace it with `vowelsInString[0]`, which is 'e' 38 | - We decrement `vowelIndex` to -1 39 | 40 | 4. Final result: 41 | - `stringArray = ['h', 'o', 'l', 'l', 'e']` 42 | - After join: `"holle"` 43 | -------------------------------------------------------------------------------- /problems/solutions/0345-reverse-vowels-of-a-string/pt/descricao.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/problems/solutions/0345-reverse-vowels-of-a-string/pt/descricao.md -------------------------------------------------------------------------------- /problems/solutions/0345-reverse-vowels-of-a-string/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 345. Reverse Vowels of a String - Explicação da Solução 2 | 3 | ## Abordagem: Coleta e Substituição de Vogais 4 | 5 | Esta solução inverte apenas as vogais de uma string enquanto mantém os demais caracteres em suas posições originais. A abordagem é feita em duas etapas: primeiro coletamos todas as vogais, depois as substituímos na ordem inversa. 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. Convertemos a string de entrada em um array de caracteres para facilitar as modificações. 10 | 2. Definimos quais caracteres são vogais (a, e, i, o, u - tanto maiúsculas quanto minúsculas). 11 | 3. Percorremos a string e coletamos todas as vogais encontradas em um array separado. 12 | 4. Percorremos novamente a string original: 13 | - Quando encontramos uma vogal, a substituímos pela última vogal coletada ainda não utilizada. 14 | - Decrementamos o índice para apontar para a próxima vogal a ser utilizada na substituição. 15 | 16 | ## Exemplo Passo a Passo: 17 | 18 | Usando o exemplo: `s = "hello"` 19 | 20 | 1. Inicialização: 21 | 22 | - `stringArray = ['h', 'e', 'l', 'l', 'o']` 23 | - `vowels = ['a', 'e', 'i', 'o', 'u']` 24 | 25 | 2. Coletar vogais: 26 | 27 | - Percorremos `stringArray` e identificamos 'e' e 'o' como vogais 28 | - `vowelsInString = ['e', 'o']` 29 | 30 | 3. Substituir vogais na ordem inversa: 31 | 32 | - `vowelIndex = 1` (último índice de `vowelsInString`) 33 | - Primeira vogal encontrada: 'e' na posição 1 34 | - Substituímos por `vowelsInString[1]`, que é 'o' 35 | - Decrementamos `vowelIndex` para 0 36 | - Segunda vogal encontrada: 'o' na posição 4 37 | - Substituímos por `vowelsInString[0]`, que é 'e' 38 | - Decrementamos `vowelIndex` para -1 39 | 40 | 4. Resultado final: 41 | - `stringArray = ['h', 'o', 'l', 'l', 'e']` 42 | - Após join: `"holle"` 43 | -------------------------------------------------------------------------------- /problems/solutions/0345-reverse-vowels-of-a-string/solution.ts: -------------------------------------------------------------------------------- 1 | function reverseVowels(s: string): string { 2 | const vowels = ["a", "e", "i", "o", "u"]; 3 | const stringArray = s.split(""); 4 | 5 | const vowelsInString: string[] = []; 6 | 7 | for (const possibleVowel of stringArray) { 8 | if (vowels.includes(possibleVowel.toLowerCase())) { 9 | vowelsInString.push(possibleVowel); 10 | } 11 | } 12 | 13 | let vowelIndex = vowelsInString.length - 1; 14 | 15 | for (let i = 0; i < stringArray.length; i++) { 16 | if (vowels.includes(stringArray[i].toLowerCase())) { 17 | stringArray[i] = vowelsInString[vowelIndex]; 18 | 19 | vowelIndex--; 20 | } 21 | } 22 | 23 | return stringArray.join(""); 24 | } 25 | -------------------------------------------------------------------------------- /problems/solutions/0387-first-unique-character-in-a-string/en/description.md: -------------------------------------------------------------------------------- 1 | # 387. First Unique Character in a String (Easy) 2 | 3 | Given a string `s`, find the **first** non-repeating character in it and 4 | return its index. If it **does not** exist, return `-1`. 5 | 6 | ## Example 1: 7 | 8 | Input: s = "leetcode" 9 | 10 | Output: 0 11 | 12 | Explanation: 13 | 14 | The character `'l'` at index 0 is the first character that does not occur at 15 | any other index. 16 | 17 | ## Example 2: 18 | 19 | Input: s = "loveleetcode" 20 | 21 | Output: 2 22 | 23 | ## Example 3: 24 | 25 | Input: s = "aabb" 26 | 27 | Output: -1 28 | 29 | ## Constraints 30 | 31 | * `1 <= s.length <= 105` 32 | * `s` consists of only lowercase English letters. 33 | -------------------------------------------------------------------------------- /problems/solutions/0387-first-unique-character-in-a-string/en/explanation.md: -------------------------------------------------------------------------------- 1 | 1. Use a dict `d` to map each char to `[first_index, count]`. 2 | 2. Loop `for i,ch in enumerate(s)`: 3 | - If `ch` not in `d`, set `d[ch]=[i,1]` 4 | - Else increment `d[ch][1]`. 5 | 3. Iterate `for _,(idx,c) in d.items()`: 6 | - If `c==1`, return `idx`. 7 | 4. Return `-1` if none. -------------------------------------------------------------------------------- /problems/solutions/0387-first-unique-character-in-a-string/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 387. First Unique Character in a String (Fácil) 2 | 3 | Dada uma string `s`, encontre o ** primeiro ** caráter não repetido nela e 4 | retornar seu índice.Se ** não existir **, retorne `-1`. 5 | 6 | ## Exemplo 1: 7 | 8 | Entrada: s = "leetcode" 9 | 10 | Saída: 0 11 | 12 | Explicação: 13 | 14 | O personagem `'l'` no índice 0 é o primeiro personagem que não ocorre em 15 | qualquer outro índice. 16 | 17 | ## Exemplo 2: 18 | 19 | Entrada: s = "loveleetCode" 20 | 21 | Saída: 2 22 | 23 | ## Exemplo 3: 24 | 25 | Entrada: s = "aabb" 26 | 27 | Saída: -1 28 | 29 | ## restrições 30 | 31 | * `1 <= s.length <= 105` 32 | * `s` consiste apenas em letras inglesas minúsculas. 33 | -------------------------------------------------------------------------------- /problems/solutions/0387-first-unique-character-in-a-string/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | 1. Crie um dicionário `d` que guarda `[índice_inicial, contagem]` de cada caractere. 2 | 2. Percorra `s` com `enumerate`: 3 | - Se o caractere não está em `d`, faça `d[ch]=[i,1]`. 4 | - Caso contrário, incremente `d[ch][1]`. 5 | 3. Para cada valor em `d.items()`, retorne o índice do primeiro com contagem 1. 6 | 4. Se não houver, retorne `-1`. -------------------------------------------------------------------------------- /problems/solutions/0387-first-unique-character-in-a-string/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def firstUniqChar(self, s: str) -> int: 3 | d = {} 4 | for idx, ch in enumerate(s): 5 | if not d.get(ch): 6 | d[ch] = [idx, 1] 7 | else: 8 | d[ch][1] += 1 9 | 10 | for ch, val in d.items(): 11 | if val[1] == 1: 12 | return val[0] 13 | 14 | return -1 15 | -------------------------------------------------------------------------------- /problems/solutions/0509-Fibonacci-Number/Solution.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | // Method that calculates the Fibonacci number for a given 'n' 3 | public static int fib(int n) { 4 | // Initializing the first two variables of the Fibonacci sequence 5 | int a = 0; // Initially, a = 0 (Fibonacci of 0) 6 | int b = 1; // b = 1 (Fibonacci of 1) 7 | int fibonacci = 0; // Variable to store the current Fibonacci number 8 | 9 | // Loop to calculate the Fibonacci sequence up to the desired number 10 | for (int i = 0; i < n; i++) { 11 | // The next Fibonacci number is the sum of the two previous ones 12 | fibonacci = a + b; 13 | 14 | // Update the value of 'b' to be the current value of 'a' 15 | b = a; 16 | 17 | // Update 'a' with the newly calculated Fibonacci value 18 | a = fibonacci; 19 | } 20 | 21 | // Return the Fibonacci value after 'n' iterations 22 | return fibonacci; 23 | } 24 | } -------------------------------------------------------------------------------- /problems/solutions/0509-Fibonacci-Number/en/description.md: -------------------------------------------------------------------------------- 1 | # 509. Fibonacci Number (Easy) 2 | 3 | The **Fibonacci numbers**, commonly denoted `F(n)` form a sequence, called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from `0` and `1`. That is, 4 | 5 | F(0) = 0, F(1) = 1 6 | F(n) = F(n - 1) + F(n - 2), for n > 1. 7 | 8 | Given `n`, calculate `F(n)`. 9 | 10 | ## Example 1: 11 | 12 | Input: n = 2 13 | Output: 1 14 | Explanation: F(2) = F(1) + F(0) = 1 + 0 = 1. 15 | 16 | ## Example 2: 17 | 18 | Input: n = 3 19 | Output: 2 20 | Explanation: F(3) = F(2) + F(1) = 1 + 1 = 2. 21 | 22 | ## Example 3: 23 | 24 | Input: n = 4 25 | Output: 3 26 | Explanation: F(4) = F(3) + F(2) = 2 + 1 = 3. 27 | 28 | ## Constraints 29 | 30 | - `0 <= n <= 30` 31 | -------------------------------------------------------------------------------- /problems/solutions/0509-Fibonacci-Number/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 509. Fibonacci Number - Solution Explanation 2 | 3 | ## Approach: Simple Recursion 4 | 5 | This solution implements the calculation of Fibonacci numbers using a direct recursive approach, following the mathematical definition of the Fibonacci sequence. 6 | 7 | ## Algorithm Logic: 8 | 9 | 1. **Base Cases**: 10 | - If n = 0, return 0 11 | - If n = 1, return 1 12 | 2. **Recursive Case**: 13 | - For n > 1, we calculate the Fibonacci number by adding the two previous Fibonacci numbers: 14 | - F(n) = F(n-1) + F(n-2) 15 | 16 | ## Step-by-Step Example: 17 | 18 | To calculate fib(4): 19 | 20 | 1. We call `fib(4)` 21 | - Not a base case, so we calculate `fib(3) + fib(2)` 22 | 2. We calculate `fib(3)` 23 | - Not a base case, so we calculate `fib(2) + fib(1)` 24 | 3. We calculate `fib(2)` 25 | - Not a base case, so we calculate `fib(1) + fib(0)` 26 | - `fib(1)` = 1 (base case) 27 | - `fib(0)` = 0 (base case) 28 | - So `fib(2)` = 1 + 0 = 1 29 | 4. Going back to `fib(3)` 30 | - `fib(2)` = 1 (already calculated) 31 | - `fib(1)` = 1 (base case) 32 | - So `fib(3)` = 1 + 1 = 2 33 | 5. Going back to `fib(4)` 34 | 35 | - `fib(3)` = 2 (already calculated) 36 | - We need to calculate `fib(2)` again 37 | - `fib(2)` = 1 (we already know) 38 | - So `fib(4)` = 2 + 1 = 3 39 | 40 | 6. Final result: `fib(4)` = 3 41 | -------------------------------------------------------------------------------- /problems/solutions/0509-Fibonacci-Number/pt/descrição.md: -------------------------------------------------------------------------------- 1 | # 509. Número de Fibonacci (Fácil) 2 | 3 | Os **números de Fibonacci**, comumente denotados como `F(n)`, formam uma sequência, chamada **sequência de Fibonacci**, de tal forma que cada número é a soma dos dois anteriores, começando por `0` e `1`. Ou seja, 4 | 5 | F(0) = 0, F(1) = 1 6 | F(n) = F(n - 1) + F(n - 2), para n > 1. 7 | 8 | Dado `n`, calcule `F(n)`. 9 | 10 | ## Exemplo 1: 11 | 12 | Entrada: n = 2 13 | Saída: 1 14 | Explicação: F(2) = F(1) + F(0) = 1 + 0 = 1. 15 | 16 | ## Exemplo 2: 17 | 18 | Entrada: n = 3 19 | Saída: 2 20 | Explicação: F(3) = F(2) + F(1) = 1 + 1 = 2. 21 | 22 | ## Exemplo 3: 23 | 24 | Entrada: n = 4 25 | Saída: 3 26 | Explicação: F(4) = F(3) + F(2) = 2 + 1 = 3. 27 | 28 | ## Restrições 29 | 30 | - `0 <= n <= 30` 31 | -------------------------------------------------------------------------------- /problems/solutions/0509-Fibonacci-Number/pt/explicação.md: -------------------------------------------------------------------------------- 1 | # 509. Fibonacci Number - Explicação da Solução 2 | 3 | ## Abordagem: Recursão Simples 4 | 5 | Esta solução implementa o cálculo do número de Fibonacci usando uma abordagem recursiva direta, que segue a definição matemática da sequência de Fibonacci. 6 | 7 | ## Lógica do Algoritmo: 8 | 9 | 1. **Casos Base**: 10 | - Se n = 0, retornamos 0 11 | - Se n = 1, retornamos 1 12 | 2. **Caso Recursivo**: 13 | - Para n > 1, calculamos o número de Fibonacci somando os dois números de Fibonacci anteriores: 14 | - F(n) = F(n-1) + F(n-2) 15 | 16 | ## Exemplo Passo a Passo: 17 | 18 | Para calcular fib(4): 19 | 20 | 1. Chamamos `fib(4)` 21 | - Não é caso base, então calculamos `fib(3) + fib(2)` 22 | 2. Calculamos `fib(3)` 23 | - Não é caso base, então calculamos `fib(2) + fib(1)` 24 | 3. Calculamos `fib(2)` 25 | - Não é caso base, então calculamos `fib(1) + fib(0)` 26 | - `fib(1)` = 1 (caso base) 27 | - `fib(0)` = 0 (caso base) 28 | - Então `fib(2)` = 1 + 0 = 1 29 | 4. Voltando para `fib(3)` 30 | - `fib(2)` = 1 (já calculado) 31 | - `fib(1)` = 1 (caso base) 32 | - Então `fib(3)` = 1 + 1 = 2 33 | 5. Voltando para `fib(4)` 34 | 35 | - `fib(3)` = 2 (já calculado) 36 | - Precisamos calcular `fib(2)` novamente 37 | - `fib(2)` = 1 (já sabemos) 38 | - Então `fib(4)` = 2 + 1 = 3 39 | 40 | 6. Resultado final: `fib(4)` = 3 41 | -------------------------------------------------------------------------------- /problems/solutions/0509-Fibonacci-Number/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def fib(self, n: int) -> int: 3 | if n == 0: 4 | return 0 5 | if n == 1: 6 | return 1 7 | 8 | fibonacci = self.fib(n - 1) + self.fib(n - 2) 9 | return fibonacci 10 | -------------------------------------------------------------------------------- /problems/solutions/0509-Fibonacci-Number/solution.ts: -------------------------------------------------------------------------------- 1 | function fib(n: number): number { 2 | if (n === 0) return 0; 3 | if (n === 1) return 1; 4 | 5 | let fibonacci: number = 0; 6 | 7 | fibonacci = fib(n - 1) + fib(n - 2); 8 | 9 | return fibonacci; 10 | } 11 | -------------------------------------------------------------------------------- /problems/solutions/0557-reverse-words-in-a-string-iii/en/description.md: -------------------------------------------------------------------------------- 1 | # 557. Reverse Words in a String III (Easy) 2 | 3 | Given a string `s`, reverse the order of characters in each word within a 4 | sentence while still preserving whitespace and initial word order. 5 | 6 | ## Example 1: 7 | 8 | 9 | 10 | Input: s = "Let's take LeetCode contest" 11 | Output: "s'teL ekat edoCteeL tsetnoc" 12 | 13 | 14 | ## Example 2: 15 | 16 | 17 | 18 | Input: s = "Mr Ding" 19 | Output: "rM gniD" 20 | 21 | 22 | ## Constraints 23 | 24 | * `1 <= s.length <= 5 * 104` 25 | * `s` contains printable **ASCII** characters. 26 | * `s` does not contain any leading or trailing spaces. 27 | * There is **at least one** word in `s`. 28 | * All the words in `s` are separated by a single space. 29 | -------------------------------------------------------------------------------- /problems/solutions/0557-reverse-words-in-a-string-iii/en/explanation.md: -------------------------------------------------------------------------------- 1 | # Explanation 2 | 3 | The problem asks to reverse each word in a given string, while maintaining the order of the words. 4 | 5 | For example: 6 | - Input: `"Let's take LeetCode contest"` 7 | - Output: `"s'teL ekat edoCteeL tsetnoc"` 8 | 9 | --- 10 | 11 | ## Solution Overview 12 | 13 | Here's what the solution does: 14 | 15 | 1. Initialize two pointers: `l` and `r` at 0. 16 | 2. Initialize an empty string `res` to store the reversed words. 17 | 3. Iterate through the string using `r`: 18 | - If `s[r]` is not a space, increment `r`. 19 | - If `s[r]` is a space, reverse the word from `l` to `r` (inclusive) and add it to `res`. 20 | - Move the pointers to the next word: increment `r` and set `l = r`. 21 | 4. After the loop, there's still one last word to reverse (since it doesn't end with a space). Reverse the remaining substring and add it to `res`. 22 | 5. Add an extra space to `res` to make sure the last word is reversed correctly. 23 | 6. Return `res[1:]` to remove the extra space at the beginning. 24 | 25 | --- 26 | 27 | ## Key Details 28 | 29 | - **Why `res += s[l:r + 1][::-1]`?** 30 | - We reverse the word (from `l` to `r`) and include the space at the end so that the next word's reversal starts after the space. 31 | 32 | - **Handling the last word:** 33 | - Since the loop ends before the last word is reversed, we handle it separately by reversing `s[l:r + 2]` and adding it to `res`. 34 | 35 | --- 36 | 37 | ## Complexity 38 | 39 | - **Time Complexity:** O(N), since we iterate through the string once. 40 | - **Space Complexity:** O(N), as we build a new string. 41 | 42 | --- 43 | 44 | ## Improvements 45 | 46 | Although this solution works, it's slightly messy because of adding an extra space and trimming at the end. An alternative approach could be: 47 | - Split the string by spaces. 48 | - Reverse each word. 49 | - Join them back with spaces. 50 | 51 | Example: 52 | ```python 53 | def reverseWords(s: str) -> str: 54 | return " ".join(word[::-1] for word in s.split(" ")) 55 | -------------------------------------------------------------------------------- /problems/solutions/0557-reverse-words-in-a-string-iii/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 557. Reverse Words in a String III (Fácil) 2 | 3 | Dada uma string `s`, reverta a ordem dos caracteres em cada palavra dentro de um 4 | sentença enquanto ainda preservando o espaço em branco e a ordem inicial das palavras. 5 | 6 | ## Exemplo 1: 7 | 8 | 9 | 10 | Entrada: s = "Vamos fazer o concurso LeetCode" 11 | Saída: "S'tel Ekat Edocteel tsetnoc" 12 | 13 | 14 | ## Exemplo 2: 15 | 16 | 17 | 18 | Entrada: s = "Sr. Ding" 19 | Saída: "rm gnid" 20 | 21 | 22 | ## restrições 23 | 24 | * `1 <= S.Length <= 5 * 104` 25 | *`s` contém imprimíveis ** ASCII ** caracteres. 26 | * `s` não contém espaços de liderança ou à direita. 27 | *Há ** pelo menos uma ** palavra em `s`. 28 | * Todas as palavras em `s` são separadas por um único espaço. 29 | -------------------------------------------------------------------------------- /problems/solutions/0557-reverse-words-in-a-string-iii/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # Explicação 2 | 3 | O problema pede para inverter cada palavra em uma string, mantendo a ordem das palavras. 4 | 5 | Por exemplo: 6 | - Entrada: `"Let's take LeetCode contest"` 7 | - Saída: `"s'teL ekat edoCteeL tsetnoc"` 8 | 9 | --- 10 | 11 | ## Visão Geral da Solução 12 | 13 | Veja o que essa solução faz: 14 | 15 | 1. Inicializa dois ponteiros: `l` e `r` em 0. 16 | 2. Inicializa uma string vazia `res` para armazenar as palavras invertidas. 17 | 3. Itera pela string usando `r`: 18 | - Se `s[r]` não é espaço, incrementa `r`. 19 | - Se `s[r]` é espaço, inverte a palavra de `l` até `r` (inclusive) e adiciona em `res`. 20 | - Move os ponteiros para a próxima palavra: incrementa `r` e define `l = r`. 21 | 4. Após o loop, ainda há a última palavra para inverter (pois não termina com espaço). Inverte essa substring e adiciona em `res`. 22 | 5. Adiciona um espaço extra em `res` para garantir que a última palavra seja invertida corretamente. 23 | 6. Retorna `res[1:]` para remover o espaço extra no início. 24 | 25 | --- 26 | 27 | ## Detalhes Importantes 28 | 29 | - **Por que `res += s[l:r + 1][::-1]`?** 30 | - Inverte a palavra (de `l` até `r`) e inclui o espaço no final para que a próxima inversão comece após o espaço. 31 | 32 | - **Tratamento da última palavra:** 33 | - Como o loop termina antes de inverter a última palavra, fazemos isso separadamente invertendo `s[l:r + 2]` e adicionando em `res`. 34 | 35 | --- 36 | 37 | ## Complexidade 38 | 39 | - **Complexidade de Tempo:** O(N), pois percorre a string uma vez. 40 | - **Complexidade de Espaço:** O(N), já que cria uma nova string. 41 | 42 | --- 43 | 44 | ## Melhorias 45 | 46 | Embora essa solução funcione, ela fica um pouco confusa por adicionar um espaço extra e cortar no final. Uma abordagem alternativa seria: 47 | - Dividir a string pelos espaços. 48 | - Inverter cada palavra. 49 | - Juntar tudo de volta com espaços. 50 | 51 | Exemplo: 52 | ```python 53 | def reverseWords(s: str) -> str: 54 | return " ".join(word[::-1] for word in s.split(" ")) 55 | -------------------------------------------------------------------------------- /problems/solutions/0557-reverse-words-in-a-string-iii/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def reverseWords(self, s: str) -> str: 3 | res = '' 4 | l, r = 0, 0 5 | 6 | while r < len(s): 7 | if s[r] != " ": 8 | r += 1 9 | else: 10 | res += s[l : r + 1][::-1] 11 | r += 1 12 | l = r 13 | 14 | res += " " 15 | res += s[l:r + 2][::-1] 16 | 17 | return res[1:] 18 | -------------------------------------------------------------------------------- /problems/solutions/0645-set-mismatch/en/description.md: -------------------------------------------------------------------------------- 1 | # 645. Set Mismatch (Easy) 2 | 3 | You have a set of integers `s`, which originally contains all the numbers from 4 | `1` to `n`. Unfortunately, due to some error, one of the numbers in `s` got 5 | duplicated to another number in the set, which results in **repetition of 6 | one** number and **loss of another** number. 7 | 8 | You are given an integer array `nums` representing the data status of this set 9 | after the error. 10 | 11 | Find the number that occurs twice and the number that is missing and return 12 | _them in the form of an array_. 13 | 14 | ## Example 1: 15 | 16 | 17 | 18 | Input: nums = [1,2,2,4] 19 | Output: [2,3] 20 | 21 | 22 | ## Example 2: 23 | 24 | 25 | 26 | Input: nums = [1,1] 27 | Output: [1,2] 28 | 29 | 30 | ## Constraints 31 | 32 | * `2 <= nums.length <= 104` 33 | * `1 <= nums[i] <= 104` 34 | -------------------------------------------------------------------------------- /problems/solutions/0645-set-mismatch/en/explanation.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/problems/solutions/0645-set-mismatch/en/explanation.md -------------------------------------------------------------------------------- /problems/solutions/0645-set-mismatch/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 645. Set Mismatch (Fácil) 2 | 3 | Você tem um conjunto de números inteiros `s`, que originalmente contém todos os números de 4 | `1` para` n`.Infelizmente, devido a algum erro, um dos números em `s` Got 5 | duplicado para outro número no conjunto, o que resulta em ** repetição de 6 | Um ** número e ** perda de outro número **. 7 | 8 | Você recebe uma matriz inteira `nums` representando o status de dados deste conjunto 9 | Após o erro. 10 | 11 | Encontre o número que ocorre duas vezes e o número que está ausente e retorne 12 | _SHE na forma de uma matriz_. 13 | 14 | ## Exemplo 1: 15 | 16 | 17 | 18 | Entrada: nums = [1,2,2,4] 19 | Saída: [2,3] 20 | 21 | 22 | ## Exemplo 2: 23 | 24 | 25 | 26 | Entrada: nums = [1,1] 27 | Saída: [1,2] 28 | 29 | 30 | ## restrições 31 | 32 | * `2 <= nums.Length <= 104` 33 | * `1 <= nums [i] <= 104` 34 | -------------------------------------------------------------------------------- /problems/solutions/0645-set-mismatch/pt/explicacao.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/problems/solutions/0645-set-mismatch/pt/explicacao.md -------------------------------------------------------------------------------- /problems/solutions/0645-set-mismatch/solution.py: -------------------------------------------------------------------------------- 1 | ## class Solution: 2 | ## def findErrorNums(self, nums: List[int]) -> List[int]: 3 | ## 4 | -------------------------------------------------------------------------------- /problems/solutions/0645-set-mismatch/solution.ts: -------------------------------------------------------------------------------- 1 | function findErrorNums(nums: number[]): number[] { 2 | const frequency: number[] = Array.from({ length: nums.length + 1 }, () => { 3 | return 0 4 | }) 5 | 6 | for (let num of nums) { 7 | frequency[num]++; 8 | } 9 | 10 | let duplicated = 0; 11 | let missing = 0; 12 | 13 | for (let i = 1; i < frequency.length; i++) { 14 | if (frequency[i] === 2) duplicated = i; 15 | if (frequency[i] === 0) missing = i; 16 | } 17 | 18 | return [duplicated, missing]; 19 | }; -------------------------------------------------------------------------------- /problems/solutions/0876-hand-of-straights/en/description.md: -------------------------------------------------------------------------------- 1 | # 876. Hand of Straights (Medium) 2 | 3 | Alice has some number of cards and she wants to rearrange the cards into 4 | groups so that each group is of size `groupSize`, and consists of `groupSize` 5 | consecutive cards. 6 | 7 | Given an integer array `hand` where `hand[i]` is the value written on the 8 | `ith` card and an integer `groupSize`, return `true` if she can rearrange the 9 | cards, or `false` otherwise. 10 | 11 | ## Example 1: 12 | 13 | 14 | 15 | Input: hand = [1,2,3,6,2,3,4,7,8], groupSize = 3 16 | Output: true 17 | Explanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8] 18 | 19 | 20 | ## Example 2: 21 | 22 | 23 | 24 | Input: hand = [1,2,3,4,5], groupSize = 4 25 | Output: false 26 | Explanation: Alice's hand can not be rearranged into groups of 4. 27 | 28 | 29 | 30 | ## Constraints 31 | 32 | * `1 <= hand.length <= 104` 33 | * `0 <= hand[i] <= 109` 34 | * `1 <= groupSize <= hand.length` 35 | 36 | **Note:** This question is the same as 1296: 37 | 38 | -------------------------------------------------------------------------------- /problems/solutions/0876-hand-of-straights/en/explanation.md: -------------------------------------------------------------------------------- 1 | # 876. Middle of the Linked List (Easy) 2 | 3 | ## Problem 4 | Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. 5 | 6 | ## Examples 7 | 1. **Input:** `head = [1,2,3,4,5]` 8 | **Output:** `[3,4,5]` 9 | 10 | 2. **Input:** `head = [1,2,3,4,5,6]` 11 | **Output:** `[4,5,6]` 12 | 13 | ## Approach 14 | Use two pointers, fast and slow: 15 | 1. Initialize `fast = head` and `slow = head`. 16 | 2. While `fast` and `fast.next` are not null: 17 | - `fast = fast.next.next` 18 | - `slow = slow.next` 19 | 3. When the loop ends, `slow` points to the middle node. Return `slow`. 20 | 21 | ## Complexity Analysis 22 | - **Time Complexity:** O(n), where n is the number of nodes (single pass). 23 | - **Space Complexity:** O(1), only two pointers used. 24 | -------------------------------------------------------------------------------- /problems/solutions/0876-hand-of-straights/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 876. Hand of Straights (Médio) 2 | 3 | Alice tem algum número de cartas e ela quer reorganizar os cartões em 4 | grupos para que cada grupo seja de tamanho `agrupamento 'e consiste em` agrupamento' 5 | cartões consecutivos. 6 | 7 | Dada uma matriz inteira `hand` onde` mão [i] `é o valor escrito no 8 | `it 'cartão e um número inteiro` agrupe', retornar `true` se ela puder reorganizar o 9 | cartões, ou `false`, caso contrário. 10 | 11 | ## Exemplo 1: 12 | 13 | 14 | 15 | Entrada: Hand = [1,2,3,6,2,3,4,7,8], Groupsize = 3 16 | Saída: true 17 | Explicação: A mão de Alice pode ser reorganizada como [1,2,3], [2,3,4], [6,7,8] 18 | 19 | 20 | ## Exemplo 2: 21 | 22 | 23 | 24 | Entrada: Hand = [1,2,3,4,5], GroupSize = 4 25 | Saída: false 26 | Explicação: A mão de Alice não pode ser reorganizada em grupos de 4. 27 | 28 | 29 | 30 | ## restrições 31 | 32 | * `1 <= hand.length <= 104` 33 | * `0 <= Hand [i] <= 109` 34 | * `1 <= agrupamento <= hand.length ' 35 | 36 | ** Nota: ** Esta pergunta é a mesma que 1296: 37 | 38 | -------------------------------------------------------------------------------- /problems/solutions/0876-hand-of-straights/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | # 876. Meio da Lista Ligada (Fácil) 2 | 3 | ## Enunciado 4 | Dado o head de uma lista ligada simples, retorne o nó do meio. Se existirem dois nós do meio, retorne o segundo. 5 | 6 | ## Exemplos 7 | 1. **Entrada:** `head = [1,2,3,4,5]` 8 | **Saída:** `[3,4,5]` 9 | 10 | 2. **Entrada:** `head = [1,2,3,4,5,6]` 11 | **Saída:** `[4,5,6]` 12 | 13 | ## Abordagem 14 | Utilize dois ponteiros, rápido e lento: 15 | 1. Inicialize `rapido = head` e `lento = head`. 16 | 2. Enquanto `rapido` e `rapido.next` existirem: 17 | - `rapido = rapido.next.next` 18 | - `lento = lento.next` 19 | 3. Ao final do loop, `lento` aponta para o nó do meio. Retorne `lento`. 20 | 21 | ## Análise de Complexidade 22 | - **Complexidade de Tempo:** O(n), onde n é o número de nós (uma única travessia). 23 | - **Complexidade de Espaço:** O(1), pois usamos apenas dois ponteiros. 24 | -------------------------------------------------------------------------------- /problems/solutions/0876-hand-of-straights/solution.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | class ListNode: 4 | def __init__(self, val=0, next=None): 5 | self.val = val 6 | self.next = next 7 | 8 | class Solution: 9 | def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]: 10 | ahead = head 11 | 12 | while ahead and ahead.next: 13 | ahead = ahead.next.next 14 | head = head.next 15 | 16 | return head -------------------------------------------------------------------------------- /problems/solutions/3090-maximum-length-substring-with-two-occurrences/en/description.md: -------------------------------------------------------------------------------- 1 | # 3090. Maximum Length Substring With Two Occurrences (Easy) 2 | 3 | You are given a string `s`. You need to find the maximum length of a substring where each character occurs at most twice. 4 | 5 | Return the length of the longest such substring. 6 | 7 | --- 8 | 9 | **Example:** 10 | 11 | **Input:** `s = "bcbbbcba"` 12 | **Output:** `4` 13 | **Explanation:** The substring `"bcbb"` is the longest one where each character appears at most twice. 14 | 15 | --- 16 | 17 | **Constraints:** 18 | 19 | - `1 <= s.length <= 100` 20 | - `s` consists of lowercase English letters. 21 | -------------------------------------------------------------------------------- /problems/solutions/3090-maximum-length-substring-with-two-occurrences/en/explanation.md: -------------------------------------------------------------------------------- 1 | ## Solution Explanation 2 | 3 | We use the **sliding window** technique to track the substring where each character occurs at most twice. 4 | 5 | - We maintain two pointers, `l` and `r`, representing the left and right boundaries of the window. 6 | - We use a `counter` dictionary to keep track of the frequency of each character in the window. 7 | - We expand the window by moving `r` to the right and adding the current character to the `counter`. 8 | - If any character appears **three times**, we shrink the window from the left (`l`) until that character appears at most twice. 9 | - During each expansion, we update `_max` to store the length of the current valid window. 10 | - Finally, we return `_max`. 11 | 12 | This ensures we always have the longest substring where no character appears more than twice. 13 | -------------------------------------------------------------------------------- /problems/solutions/3090-maximum-length-substring-with-two-occurrences/pt/descricao.md: -------------------------------------------------------------------------------- 1 | # 3090. Maximum Length Substring With Two Occurrences (Fácil) 2 | 3 | Dado um string `s`, você precisa encontrar o comprimento máximo de uma substring onde cada caractere aparece no máximo duas vezes. 4 | 5 | Retorne o comprimento dessa substring mais longa. 6 | 7 | --- 8 | 9 | **Exemplo:** 10 | 11 | **Entrada:** `s = "bcbbbcba"` 12 | **Saída:** `4` 13 | **Explicação:** A substring `"bcbb"` é a mais longa onde cada caractere aparece no máximo duas vezes. 14 | 15 | --- 16 | 17 | **Restrições:** 18 | 19 | - `1 <= s.length <= 100` 20 | - `s` contém apenas letras minúsculas do alfabeto inglês. 21 | -------------------------------------------------------------------------------- /problems/solutions/3090-maximum-length-substring-with-two-occurrences/pt/explicacao.md: -------------------------------------------------------------------------------- 1 | ## Explicação da Solução 2 | 3 | Utilizamos a técnica de **janela deslizante (sliding window)** para controlar a substring onde cada caractere aparece no máximo duas vezes. 4 | 5 | - Mantemos dois ponteiros, `l` e `r`, que representam as extremidades da janela. 6 | - Um dicionário `counter` armazena a contagem de cada caractere na janela. 7 | - Expandimos a janela movendo `r` para a direita e adicionamos o caractere atual no `counter`. 8 | - Se algum caractere aparecer **três vezes**, reduzimos a janela pela esquerda (`l`) até que ele apareça no máximo duas vezes. 9 | - Durante cada expansão, atualizamos `_max` para armazenar o comprimento da janela atual válida. 10 | - No final, retornamos `_max`. 11 | 12 | Assim, garantimos sempre a substring mais longa onde cada caractere ocorre no máximo duas vezes. 13 | -------------------------------------------------------------------------------- /problems/solutions/3090-maximum-length-substring-with-two-occurrences/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maximumLengthSubstring(self, s: str) -> int: 3 | l, r = 0, 0 4 | _max = 1 5 | counter = {} 6 | 7 | counter[s[0]] = 1 8 | 9 | while r < len(s) - 1: 10 | r+=1 11 | if counter.get(s[r]): 12 | counter[s[r]] += 1 13 | else: 14 | counter[s[r]] = 1 15 | 16 | while counter[s[r]] == 3: 17 | counter[s[l]] -= 1 18 | l += 1 19 | _max = max(_max, r-l+1) 20 | 21 | return _max -------------------------------------------------------------------------------- /problems/summary.md: -------------------------------------------------------------------------------- 1 | # Problems Summary 2 | 3 | This summary includes the challenges from LeetCode that we have already solved, **organized by ID**. Each problem offers an opportunity to practice and improve our algorithmic skills, from basic concepts to advanced topics. 4 | 5 | - **1** - [Two Sum](solutions/0001-two-sum/solution.py) 6 | - **2** - [Add Two Numbers](solutions/0002-add-two-numbers/solution.py) 7 | - **3** - [Longest Substring Without Repeating Characters](solutions/0003-longest-substring-without-repeating-characters/solution.ts) 8 | - **9** - [Polindrome Number](solutions/0009-polindrome-number/solution.py) 9 | - **13** - [Roman to Integer (Easy)](solutions/0013-roman-to-integer/solution.py) 10 | - **14** - [Longest Common Prefix](solutions/0014-longest-common-prefix/solution.py) 11 | - **20** - [Valid Parentheses](solutions/0020-valid-parentheses/solution.ts) 12 | - **21** - [Merge Two Sorted Lists](solutions/0021-merge-two-sorted-lists/solution.py) 13 | - **35** - [Search Insert Position](solutions/0035-search-insert-position/solution.ts) 14 | - **70** - [Climbing Stairs](solutions/0070-climbing-stairs/solution.py) 15 | - **112** - [Path Sum](solutions/0112-path-sum/solution.py) 16 | - **141** - [Linked List Cycle](solutions/0141-linked-list-cycle/solution.py) 17 | - **148** - [Sort List](solutions/0148-sort-list/solution.py) 18 | - **191** - [Number of 1 Bits](solutions/0191-number-of-1-bits/solution.ts) 19 | - **206** - [Reverse Linked List](solutions/0206-reverse-linked-list/solution.py) 20 | - **342** - [Power of Four](solutions/0342-power-of-four/solution.ts) 21 | - **345** - [Reverse Vowels of a String](solutions/0345-reverse-vowels-of-a-string/solution.py) 22 | - **387** - [First Unique Character in a String](solutions/0387-first-unique-character-in-a-string/solution.py) 23 | - **509** - [Fibonacci Number](solutions/0509-fibonacci-number/solution.py) 24 | - **557** - [Reverse Words in a String III](solutions/0557-reverse-words-in-a-string-iii/solution.py) 25 | - **876** - [Middle of the Linked List](solutions/0876-hand-of-straights/solution.py) 26 | - **3090** - [Maximum Length Substring With Two Occurrences](solutions/3090-maximum-length-substring-with-two-occurrences/solution.py) 27 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/caio-andres/leetcode-challenge/696ddd3f62f0aba996c23d1983c19fa2aee46400/requirements.txt --------------------------------------------------------------------------------