ゼロから始めるLeetCode 目次

# 概要

海外ではエンジニアの面接においてコーディングテストというものが行われるらしく、多くの場合、特定の関数やクラスをお題に沿って実装するという物がメインである。

どうやら多くのエンジニアはその対策としてLeetCodeなるサイトで対策を行うようだ。

早い話が本場でも行われているようなコーディングテストに耐えうるようなアルゴリズム力を鍛えるサイトであり、海外のテックカンパニーでのキャリアを積みたい方にとっては避けては通れない道である。

と、仰々しく書いてみましたが、私は今のところそういった面接を受ける予定はありません。

ただ、ITエンジニアとして人並みのアルゴリズム力くらいは持っておいた方がいいだろうということで不定期に問題を解いてその時に考えたやり方をメモ的に書いていこうかと思います。

[Leetcode](https://leetcode.com/)

Python3で解いています。

[技術ブログ](https://kueharx.blogspot.com/)始めました。

このシリーズはQiitaでの投稿は100回を目処に終了しました。
とはいえ問題自体はこれからも解いていく予定なのでそちらが気になる方は上述の技術ブログへどうぞ。

**[まとめ記事](https://qiita.com/KueharX/items/3757d9f6c46338ed00b6)を書いてみました。**

# リンク集

この記事をストックしておくと新しい記事の追加時に通知されます。

コードだけ見たい方はこちらの
[Github](https://github.com/Kuehar/LeetCode)をご覧ください。


番号はLeetCodeの問題へのリンク、問題のリンクは解説記事についてのリンクです。

間違えているリンク等あればコメント頂けると幸いです。


| Day| 番号　|     問題 　|          難易度          |
|:-------:|:---------------|:------------------:|:--------------------:|
|1|[1389](https://leetcode.com/problems/create-target-array-in-the-given-order/)|[Create Target Array in the Given Order](https://qiita.com/KueharX/items/58d288348a5b39f7898d)|Easy|
|2|[1108](https://leetcode.com/problems/defanging-an-ip-address/)| [Defanging an IP Address](https://qiita.com/KueharX/items/85a13e7329f5c93b317b)|Easy|
|3|[1313](https://leetcode.com/problems/decompress-run-length-encoded-list/)| [Decompress Run-Length Encoded List](https://qiita.com/KueharX/items/c6b7d47ff6209fc96593)|Easy|
|4|[938](https://leetcode.com/problems/range-sum-of-bst/)| [Range Sum of BST](https://qiita.com/KueharX/items/f0182e346828eb5cfd09)|Easy|
|5|[1266](https://leetcode.com/problems/minimum-time-visiting-all-points/)| [Minimum Time Visiting All Points](https://qiita.com/KueharX/items/7949b94ac52e1b81147c)|Easy|
|6|[1342](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/)| [Number of Steps to Reduce a Number to Zero](https://qiita.com/KueharX/items/fb274973c9fc7cd920e3)|Easy|
|7|[104](https://leetcode.com/problems/maximum-depth-of-binary-tree/)| [Maximum Depth of Binary Tree](https://qiita.com/KueharX/items/539024dbb9a91305a86a)|Easy|
|8|[1302](https://leetcode.com/problems/deepest-leaves-sum/)| [Deepest Leaves Sum](https://qiita.com/KueharX/items/130795e0efc26d71897c)|Medium|
|9|[701](https://leetcode.com/problems/insert-into-a-binary-search-tree/)| [Insert into a Binary Search Tree](https://qiita.com/KueharX/items/5cc45adb826cf66ca8ab)|Medium|
|10|[1431](https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/)| [Kids With the Greatest Number of Candies](https://qiita.com/KueharX/items/62f36c578bf2def36a82)|Easy|
|11|[1315](https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent/)| [Sum of Nodes with Even-Valued Grandparent](https://qiita.com/KueharX/items/edd85ca15a78e8b1c335)|Medium|
|12|[617](https://leetcode.com/problems/merge-two-binary-trees)| [Merge Two Binary Trees](https://qiita.com/KueharX/items/7466834c494bf4de6d90)|Easy|
|13|[338](https://leetcode.com/problems/counting-bits/)| [Counting Bits](https://qiita.com/KueharX/items/98dcdb1b82d39c464a92)|Medium|
|14|[136](https://leetcode.com/problems/single-number/)| [Single Number](https://qiita.com/KueharX/items/fd12c8b8938798afcc8a)|Easy|
|15|[283](https://leetcode.com/problems/move-zeroes/)| [Move Zeroes](https://qiita.com/KueharX/items/edf03e6ac08feeac3198)|Easy|
|16|[344](https://leetcode.com/problems/reverse-string/)| [Reverse String](https://qiita.com/KueharX/items/27554500d3c7b2347b4c)|Easy|
|17|[169](https://leetcode.com/problems/majority-element/)| [Majority Element](https://qiita.com/KueharX/items/fac33d3e067cccfed148)|Easy|
|18|[53](https://leetcode.com/problems/maximum-subarray/)| [Maximum Subarray](https://qiita.com/KueharX/items/837a2bab7e2f6d94d449)|Easy|
|19|[121](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)| [Best Time to Buy and Sell Stock](https://qiita.com/KueharX/items/f89c2c1b7b15a10f86fc)|Easy|
|20|[134](https://leetcode.com/problems/gas-station/)| [Gas Station](https://qiita.com/KueharX/items/7bc4792c940e722ca7eb)|Medium|
|21|[448](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/)| [Find All Numbers Disappeared in an Array](https://qiita.com/KueharX/items/7ced157c3a103b0e39e0)|Easy|
|22|[141](https://leetcode.com/problems/linked-list-cycle/)| [Linked List Cycle](https://qiita.com/KueharX/items/20f411ebf1c53cff2208)|Easy|
|23|[226](https://leetcode.com/problems/invert-binary-tree/)| [Invert Binary Tree](https://qiita.com/KueharX/items/0f5b1387bae86bbe85c6)|Easy|
|24|[21](https://leetcode.com/problems/merge-two-binary-trees/)| [Merge Two Sorted Lists](https://qiita.com/KueharX/items/7112e8bd9dbf69f5c083)|Easy|
|25|[70](https://leetcode.com/problems/climbing-stairs/)| [Climbing Stairs](https://qiita.com/KueharX/items/5a8993968c995b074737)|Easy|
|26|[94](https://leetcode.com/problems/binary-tree-inorder-traversal/)| [Binary Tree Inorder Traversal](https://qiita.com/KueharX/items/13b85b716d185698d077)|Easy|
|27|[101](https://leetcode.com/problems/symmetric-tree/)| [Symmetric Tree](https://qiita.com/KueharX/items/05d78e039e53c1b67bf3)|Easy|
|28|[198](https://leetcode.com/problems/house-robber/)| [House Robber](https://qiita.com/KueharX/items/ad01fc743042cf2fdb2a)|Easy|
|29|[46](https://leetcode.com/problems/permutations/)| [Permutations](https://qiita.com/KueharX/items/6885be4c1da6e6a2b9a0)|Medium|
|30|[234](https://leetcode.com/problems/palindrome-linked-list/)| [Palindrome Linked List](https://qiita.com/KueharX/items/73ec43d8c4f6da343fcd)|Easy|
|31|[581](https://leetcode.com/problems/shortest-unsorted-continuous-subarray/)| [Shortest Unsorted Continuous Subarray](https://qiita.com/KueharX/items/4d1f1623503f20f70d0b)|Easy|
|32|[437](https://leetcode.com/problems/path-sum-iii/)| [Path Sum III](https://qiita.com/KueharX/items/de5f70a64667cfb04442)|Easy|
|33|[1](https://leetcode.com/problems/two-sum/)| [Two Sum](https://qiita.com/KueharX/items/fed16d68247ffbc2796c)|Easy|
|34|[118](https://leetcode.com/problems/pascals-triangle/)| [Pascal's Triangle](https://qiita.com/KueharX/items/75e711c6b051685d490c)|Easy|
|35|[160](https://leetcode.com/problems/intersection-of-two-linked-lists/)| [Intersection of Two Linked Lists](https://qiita.com/KueharX/items/f9c01184085586fbe491)|Easy|
|36|[155](https://leetcode.com/problems/min-stack/)| [Min Stack](https://qiita.com/KueharX/items/e0fe029974c5e26a0b4f)|Easy|
|37|[105](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)| [Construct Binary Tree from Preorder and Inorder Traversal](https://qiita.com/KueharX/items/c5442e4cd3baa6bb1ce0)|Medium|
|38|[208](https://leetcode.com/problems/implement-trie-prefix-tree/)| [Implement Trie (Prefix Tree)](https://qiita.com/KueharX/items/c4dc14c167a4a179ba63)|Medium|
|39|[494](https://leetcode.com/problems/target-sum/)| [Target Sum](https://qiita.com/KueharX/items/cd08167d7626c2be8787)|Medium|
|40|[114](https://leetcode.com/problems/flatten-binary-tree-to-linked-list/)| [Flatten Binary Tree to Linked List](https://qiita.com/KueharX/items/3f0af8806a720999bf45)|Medium|
|41|[394](https://leetcode.com/problems/decode-string/)| [Decode String](https://qiita.com/KueharX/items/4228d2a815922b1631be)|Medium|
|42|[2](https://leetcode.com/problems/add-two-numbers/)| [Add Two Numbers](https://qiita.com/KueharX/items/4c2734a5d0b5db87f1b3)|Medium|
|43|[5](https://leetcode.com/problems/longest-palindromic-substring/)| [Longest Palindromic Substring](https://qiita.com/KueharX/items/33f03dec9919b71ef3c0)|Medium|
|44|[543](https://leetcode.com/problems/diameter-of-binary-tree/)| [Diameter of Binary Tree](https://qiita.com/KueharX/items/117f939714ea26ab72c6)|Easy|
|45|[1379](https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/)| [Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://qiita.com/KueharX/items/013008af197ae14fcc09)|Medium|
|46|[406](https://leetcode.com/problems/queue-reconstruction-by-height/)| [Queue Reconstruction by Height](https://qiita.com/KueharX/items/3a3b4c95a1e98cf799e0)|Medium|
|47|[14](https://leetcode.com/problems/longest-common-prefix/)| [Longest Common Prefix](https://qiita.com/KueharX/items/b97dbbcb697585924d30)|Easy|
|48|[26](https://leetcode.com/problems/remove-duplicates-from-sorted-array/)| [Remove Duplicates from Sorted Array](https://qiita.com/KueharX/items/f234d8beab96328a171a)|Easy|
|49|[1323](https://leetcode.com/problems/maximum-69-number/)| [Maximum 69 Number](https://qiita.com/KueharX/items/2d18458c80aa39a0c386)|Easy|
|50|[739](https://leetcode.com/problems/daily-temperatures/)| [Daily Temperatures](https://qiita.com/KueharX/items/eccc225ccab38969e23d)|Medium|
|51|[647](https://leetcode.com/problems/palindromic-substrings/)| [Palindromic Substrings](https://qiita.com/KueharX/items/eadca192b6bdea7fedab)|Medium|
|52|[1351](https://leetcode.com/problems/palindromic-substrings/)| [Count Negative Numbers in a Sorted Matrix」](https://qiita.com/KueharX/items/05685ec9f94d8aa0f26c)|Medium|
|53|[1365](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/submissions/)| [How Many Numbers Are Smaller Than the Current Number](https://qiita.com/KueharX/items/77f347c2e95dad58333b)|Easy|
|54|[1290](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/)| [Convert Binary Number in a Linked List to Integer](https://qiita.com/KueharX/items/1e2056a0fa5fee81381a)|Easy|
|55|[22](https://leetcode.com/problems/generate-parentheses/)| [Generate Parentheses](https://qiita.com/KueharX/items/45a1e18607a0f4e8094e)|Medium|
|56|[1480](https://leetcode.com/problems/running-sum-of-1d-array/)| [Running Sum of 1d Array](https://qiita.com/KueharX/items/483a52cc3b44f52bbe3a)|Easy|
|57|[35](https://leetcode.com/problems/search-insert-position/)| [ Search Insert Position](https://qiita.com/KueharX/items/a3ba02d7a9c29136537b)|Easy|
|58|[20](https://leetcode.com/problems/valid-parentheses/)| [Valid Parentheses](https://qiita.com/KueharX/items/053b6903b5059a781baa)|Easy|
|59|[1221](https://leetcode.com/problems/split-a-string-in-balanced-strings/)| [Split a String in Balanced Strings](https://qiita.com/KueharX/items/9dd7c8c8238c32de9400)|Easy|
|60|[1481](https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals/)| [Least Number of Unique Integers after K Removals](https://qiita.com/KueharX/items/78d5ec5a144597304f91)|Medium|
|61|[7](https://leetcode.com/problems/reverse-integer/)| [Reverse Integer](https://qiita.com/KueharX/items/c2fcff8d439c5259d91e)|Easy|
|62|[83](https://leetcode.com/problems/remove-duplicates-from-sorted-list/)| [Remove Duplicates from Sorted List](https://qiita.com/KueharX/items/0dbe2ebde8aa5dd7432d)|Easy|
|63|[195](https://leetcode.com/problems/tenth-line/)| [Tenth Line](https://qiita.com/KueharX/items/5c88d0a07201ff0fd16f)|Easy|
|64|[287](https://leetcode.com/problems/find-the-duplicate-number/)| [Find the Duplicate Number](https://qiita.com/KueharX/items/17081ff496e370e303e2)|Medium|
|65|[560](https://leetcode.com/problems/subarray-sum-equals-k/)| [Subarray Sum Equals K](https://qiita.com/KueharX/items/ed07eb4d7a967baa6d1c)|Medium|
|66|[438](https://leetcode.com/problems/subarray-sum-equals-k/)| [Find All Anagrams in a String](https://qiita.com/KueharX/items/dfa635edc45a4e7dc978)|Medium|
|67|[1486](https://leetcode.com/problems/xor-operation-in-an-array/)| [XOR Operation in an Array](https://qiita.com/KueharX/items/3f12e797009caf8ce131)|Easy|
|68|[709](https://leetcode.com/problems/to-lower-case/)| [To Lower Case](https://qiita.com/KueharX/items/e97ae6928fd2b61300c4)|Easy|
|69|[279](https://leetcode.com/problems/perfect-squares/)| [Perfect Squares](https://qiita.com/KueharX/items/72aa31599033ff4aca70)|Medium|
|70|[295](https://leetcode.com/problems/find-median-from-data-stream/)| [Find Median from Data Stream](https://qiita.com/KueharX/items/a0c9a2527f21f5e27350)|Hard|
|71|[1496](https://leetcode.com/problems/path-crossing/)| [Path Crossing](https://qiita.com/KueharX/items/baf18eaa44d68944a283)|Easy|
|72|[1498](https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/)| [Number of Subsequences That Satisfy the Given Sum Condition](https://qiita.com/KueharX/items/cde0002da7e486350fdb)|Medium|
|73|[1491](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/)| [Average Salary Excluding the Minimum and Maximum Salary](https://qiita.com/KueharX/items/2655d0438d3a86ccbc07)|Easy|
|74|[12](https://leetcode.com/problems/integer-to-roman/)| [Integer to Roman](https://qiita.com/KueharX/items/4be10ce7f2bd98a79849)|Medium|
|75|[15](https://leetcode.com/problems/3sum/)| [3Sum](https://qiita.com/KueharX/items/0eb53bc1a9a17005abb2)|Medium|
|76|[3](https://leetcode.com/problems/longest-substring-without-repeating-characters/)| [Longest Substring Without Repeating Characters](https://qiita.com/KueharX/items/a54c6d9dd30bb63f631b)|Medium|
|77|[1502](https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/)| [Can Make Arithmetic Progression From Sequence](https://qiita.com/KueharX/items/83bdea821a828b914c4e)|Easy|
|78|[206](https://leetcode.com/problems/reverse-linked-list/)| [Reverse Linked List](https://qiita.com/KueharX/items/f408439e5d7a8bab1e8f)|Easy|
|79|[1282](https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to/)| [Group the People Given the Group Size They Belong To](https://qiita.com/KueharX/items/9b363058156070ca5a0a)|Medium|
|80|[703](https://leetcode.com/problems/kth-largest-element-in-a-stream/)| [Kth Largest Element in a Stream](https://qiita.com/KueharX/items/8999b2b903596639fbfa)|Easy|
|81|[347](https://leetcode.com/problems/top-k-frequent-elements/)| [Top K Frequent Elements](https://qiita.com/KueharX/items/d56d214fcfe5f9c1b4da)|Medium|
|82|[392](https://leetcode.com/problems/is-subsequence/)| [Is Subsequence](https://qiita.com/KueharX/items/ddf57a3f819e70f7e61f)|Easy|
|83|[102](https://leetcode.com/problems/binary-tree-level-order-traversal/)| [Binary Tree Level Order Traversal](https://qiita.com/KueharX/items/fa4762faa0b2831d2116)|Medium|
|84|[142](https://leetcode.com/problems/linked-list-cycle-ii/)| [Linked List Cycle Ⅱ](https://qiita.com/KueharX/items/5ce08b24aaf74e44951c)|Medium|
|85|[6](https://leetcode.com/problems/zigzag-conversion/)| [ZigZag Conversion](https://qiita.com/KueharX/items/777868c9914317a65cd2)|Medium|
|86|[33](https://leetcode.com/problems/search-in-rotated-sorted-array/)| [Search in Rotated Sorted Array](https://qiita.com/KueharX/items/6a43823893682500fbf7)|Medium|
|87|[1512](https://leetcode.com/problems/number-of-good-pairs/)| [Number of Good Pairs](https://qiita.com/KueharX/items/f31bb0b6f4d2b74f3d8f)|Easy|
|88|[139](https://leetcode.com/problems/word-break/)| [ Word Break](https://qiita.com/KueharX/items/ac025ce072d98751e688)|Medium|
|89|[62](https://leetcode.com/problems/unique-paths/)| [Unique Paths]([https://qiita.com/KueharX/items/40046a9ee9a2e675ee13](https://qiita.com/KueharX/items/40046a9ee9a2e675ee13))|Medium|
|90|[1011](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/)| [Capacity To Ship Packages Within D Days](https://qiita.com/KueharX/items/3ac6d0260c832d2daf65)|Medium|
|91|[153](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/)| [Find Minimum in Rotated Sorted Array](https://qiita.com/KueharX/items/5b88fb023d7be19e778b)|Medium|
|92|[4](https://leetcode.com/problems/median-of-two-sorted-arrays/)| [Median of Two Sorted Arrays](https://qiita.com/KueharX/items/71ab93587eab703caab1)|Hard|
|93|[49](https://leetcode.com/problems/group-anagrams/)|[Group Anagrams](https://qiita.com/KueharX/items/5fdb75638c3fa0cfe657)|Medium|
|94|[929](https://leetcode.com/problems/unique-email-addresses/)| [Unique Email Addresses](https://qiita.com/KueharX/items/432198bf73c6d047c501)|Easy|
|95|[82](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/)| [Remove Duplicates from Sorted List II](https://qiita.com/KueharX/items/860d1c227ddb8cba0a61)|Medium|
|96|[78](https://leetcode.com/problems/subsets/)| [Subsets](https://qiita.com/KueharX/items/59c73080910983893a46)|Medium|
|97|[349](https://leetcode.com/problems/intersection-of-two-arrays/)| [Intersection of Two Arrays](https://qiita.com/KueharX/items/a8cc7831fc430e9340ca)|Easy|
|98|[39](https://leetcode.com/problems/combination-sum/)| [Combination Sum](https://qiita.com/KueharX/items/b8bce594f4663af18f0e)|Medium|
|99|[112](https://leetcode.com/problems/path-sum/)| [Path Sum](https://qiita.com/KueharX/items/32eb0395b068a59d9722)|Easy|
|100|[108](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/)| [Convert Sorted Array to Binary Search Tree](https://qiita.com/KueharX/items/c7f88204cdba42144d9b)|Easy|