文件名称:LeetCode判断字符串是否循环-Leetcode-Java-:Leetcode-Java-
文件大小:21KB
文件格式:ZIP
更新时间:2024-07-20 23:45:50
系统开源
LeetCode判断字符串是否循环 Leetcode-Java- 一.(Sort类): 350. Intersection of Two Arrays II a.首先用HashMap遍历一遍数组nums1,Key值储存数组元素,Value(初始值为1)值储存重复元素出现次数,每出现一次加1; b.用List储存nums2中与nums1开始intersection的元素,当遇到map中包含的Key时,才判断对应Value是否大于1,是的话,将对应的nums2[i],存入result中;这是为了防止当nums1的length小于nums2时,会重复储存nums2中相同数组元素的情况,举例:nums1={1},nums2={1,1},如果对应value不减一的话,result会为[1,1],但实际result应为[1]。 349. Intersection of Two Arrays 用Set遍历nums1,根据Set的方法性质,重复数组元素会被去除,用List储存nums2中与nums1相同的元素,如果set中remove掉了对应元素,则res中addnums2数组元素,再新建数组储存对应
【文件预览】:
Leetcode-Java--master
----148. Sort List.java(956B)
----62.Unich Paths.java(473B)
----75. Sort Colors.java(469B)
----274. H-Index.java(313B)
----237. Delete Node in a Linked List.java(141B)
----217. Contains Duplicate.java(280B)
----350. Intersection of Two Arrays II.java(842B)
----242. Valid Anagram.java(437B)
----448. Find All Numbers Disappeared in an Array.java(389B)
----283. Move Zeroes.java(322B)
----169. Majority Element.java(170B)
----268. Missing Number.java(196B)
----136. Single Number.java(182B)
----1. Two Sum.java(366B)
----141. Linked List Cycle.java(321B)
----414. Third Maximum Number.java(403B)
----138. Copy List with Random Pointer.java(2KB)
----21. Merge Two Sorted Lists.java(401B)
----485. Max Consecutive Ones.java(315B)
----445. Add Two Numbers II.java(833B)
----86. Partition List.java(531B)
----234. Palindrome Linked List.java(695B)
----83. Remove Duplicates from Sorted List.java(343B)
----143. Reorder List.java(1KB)
----109. Convert Sorted List to Binary Search Tree.java(619B)
----496. Next Greater Element I.java(573B)
----100. Same Tree.java(300B)
----219. Contains Duplicate II.java(410B)
----160. Intersection of Two Linked Lists.java(541B)
----147. Insertion Sort List.java(449B)
----README.md(11KB)
----206. Reverse Linked List.java(325B)
----179. Largest Number.java(629B)
----2. Add Two Numbers.java(567B)
----349. Intersection of Two Arrays.java(426B)
----142. Linked List Cycle II.java(398B)
----203. Remove Linked List Elements.java(396B)
----56. Merge Intervals.java(620B)
----328. Odd Even Linked List.java(381B)