文件名称:LeetCode判断字符串是否循环-myLeetcode:leetcode刷题日志
文件大小:57KB
文件格式:ZIP
更新时间:2024-07-20 23:39:08
系统开源
LeetCode判断字符串是否循环
myLeetcode
leetcode刷题日志
Array
array-1-star
Easy
20190129
给出数组和target,从数组中找出2个数之和等于target,保证只有一组解
Answer
用一个map记录每个数字的位置,扫一遍数组,对每个数字a若target-a的count不为0即为解。解决重复问题:若遇到重复,则把key加上一个固定的大数,保证在map中重复的数字有不同pos。不用multimap原因:麻烦。
better
solution
unordered_map
unordered_map
【文件预览】:
myLeetcode-master
----misc()
--------195. Tenth Line.sh(166B)
--------461. Hamming Distance.cpp(221B)
--------338. Counting Bits.cpp(544B)
--------46. Permutations.cpp(671B)
--------136. Single Number.cpp(294B)
--------406. Queue Reconstruction by Height.cpp(742B)
----3Tree()
--------103. Binary Tree Zigzag Level Order Traversal.cpp(966B)
--------654. Maximum Binary Tree.cpp(899B)
--------101. Symmetric Tree.cpp(633B)
--------701. Insert into a Binary Search Tree.cpp(576B)
--------919. Complete Binary Tree Inserter.cpp(2KB)
--------106. Construct Binary Tree from Inorder and Postorder Traversal.cpp(1019B)
--------988. Smallest String Starting From Leaf.cpp(594B)
--------563. Binary Tree Tilt.cpp(621B)
--------116. Populating Next Right Pointers in Each Node.cpp(1KB)
--------606. Construct String from Binary Tree.cpp(903B)
--------889. Construct Binary Tree from Preorder and Postorder Traversal.cpp(2KB)
--------637. Average of Levels in Binary Tree.cpp(783B)
--------515. Find Largest Value in Each Tree Row.cpp(815B)
--------687. Longest Univalue Path.cpp(2KB)
--------104. Maximum Depth of Binary Tree.cpp(369B)
--------589. N-ary Tree Preorder Traversal.cpp(695B)
--------993. Cousins in Binary Tree.cpp(1KB)
--------872. Leaf-Similar Trees.cpp(1KB)
--------94. Binary Tree Inorder Traversal.cpp(1KB)
--------653. Two Sum IV - Input is a BST.cpp(888B)
--------113. Path Sum II.cpp(1KB)
--------117. Populating Next Right Pointers in Each Node II.cpp(1KB)
--------226. Invert Binary Tree.cpp(478B)
--------572. Subtree of Another Tree.cpp(867B)
--------897. Increasing Order Search Tree.cpp(820B)
--------222. Count Complete Tree Nodes.cpp(1KB)
--------129. Sum Root to Leaf Numbers.cpp(902B)
--------501. Find Mode in Binary Search Tree.cpp(1KB)
--------111. Minimum Depth of Binary Tree.cpp(882B)
--------98. Validate Binary Search Tree.cpp(1KB)
--------105. Construct Binary Tree from Preorder and Inorder Traversal.cpp(991B)
--------107. Binary Tree Level Order Traversal II.cpp(1004B)
--------543. Diameter of Binary Tree.cpp(579B)
--------236. Lowest Common Ancestor of a Binary Tree.cpp(640B)
--------508. Most Frequent Subtree Sum.cpp(1KB)
--------513. Find Bottom Left Tree Value.cpp(736B)
--------257. Binary Tree Paths.cpp(844B)
--------865. Smallest Subtree with all the Deepest Nodes.cpp(2KB)
--------437. Path Sum III.cpp(845B)
--------112. Path Sum.cpp(908B)
--------559. Maximum Depth of N-ary Tree.cpp(464B)
--------617. Merge Two Binary Trees.cpp(616B)
--------671. Second Minimum Node In a Binary Tree.cpp(824B)
--------429. N-ary Tree Level Order Traversal.cpp(1KB)
--------404. Sum of Left Leaves.cpp(611B)
--------979. Distribute Coins in Binary Tree.cpp(615B)
--------590. N-ary Tree Postorder Traversal.cpp(931B)
--------987. Vertical Order Traversal of a Binary Tree.cpp(2KB)
--------235. Lowest Common Ancestor of a Binary Search Tree.cpp(963B)
--------199. Binary Tree Right Side View.cpp(789B)
--------144. Binary Tree Preorder Traversal.cpp(649B)
--------965. Univalued Binary Tree.cpp(598B)
--------700. Search in a Binary Search Tree.cpp(470B)
--------102. Binary Tree Level Order Traversal.cpp(840B)
--------110. Balanced Binary Tree.cpp(590B)
--------951. Flip Equivalent Binary Trees.cpp(650B)
--------100. Same Tree.cpp(504B)
--------108. Convert Sorted Array to Binary Search Tree.cpp(700B)
--------814. Binary Tree Pruning.cpp(557B)
--------669. Trim a Binary Search Tree.cpp(955B)
--------538. Convert BST to Greater Tree.cpp(783B)
----5Linked List()
--------2. Add Two Numbers.cpp(986B)
----2String()
--------3. Longest Substring Without Repeating Characters.cpp(589B)
--------804. Unique Morse Code Words.cpp(627B)
--------22. Generate Parentheses.cpp(550B)
--------929. Unique Email Addresses.cpp(1KB)
--------6. ZigZag Conversion.cpp(1KB)
--------5. Longest Palindromic Substring.cpp(945B)
--------709. To Lower Case.cpp(258B)
--------771. Jewels and Stones.cpp(437B)
----LICENSE(11KB)
----.gitignore(330B)
----README.md(24KB)
----1Array()
--------283. Move Zeroes.cpp(1KB)
--------1. Two Sum.cpp(1KB)
--------665. Non-decreasing Array.cpp(506B)
----6Math()
--------69. Sqrt(x).cpp(543B)
--------7. Reverse Integer.cpp(640B)
--------89. Gray Code.cpp(417B)