首页 > 其他 > 详细

leetcode - summer2020

时间:2020-06-14 10:23:00      阅读:38      评论:0      收藏:0      [点我收藏+]

2020/06/07 

[001] 24. Swap Nodes in Pairs (LinkedList - Java)

  - Description: https://leetcode.com/problems/swap-nodes-in-pairs/

  - Submission Time + Difficulty: 1, 5 (1 ~ 10)

  - dummy head, border case

 

[002] 61. Rotate List (LinkedList - Java)

  - Description: https://leetcode.com/problems/rotate-list/

  - Submission Time + Difficulty: 2, 5 (1 ~ 10)

  - switch direction since the list is only single direction.

 

[003] 205. Isomorphic Strings (HashTable - Java)

  - Description: https://leetcode.com/problems/isomorphic-strings/

  - Submission Time + Difficulty: 3, 4 (1 ~ 10)

  - return false when two different characters in string s match to the same character in string t.

  - syntax: h.containsKey(o), h.containsValue(o), h.put(key, value), h.get(key)

       Character.toString(c); s.charAt(index) // String <=> char

 

[004] 771. Jewels and Stones (HashTable - Java)

  - Description: https://leetcode.com/problems/jewels-and-stones/

  - Submission Time + Difficulty: 1, 2 (1 ~ 10)

 

[005] 202. Happy Number (HashSet - Java)

  - Description: https://leetcode.com/problems/happy-number/

  - Submission Time + Difficulty: 1, 4 (1 ~ 10)

  - set ~ general interface to a set-like collection // hashset ~ a specific implementation of the set interface

 

 

2020/06/08 

[006] 692. Top K Frequent Words (vector, custom sort - C++)

  - Description: https://leetcode.com/problems/top-k-frequent-words/

  - Submission Time + Difficulty: 1, 6 (1 ~ 10)

  - use a map to match each string with its frequency in the string array. Save (int, string) into an array with element type pair<int, string> Sort it in decreasing order of int and increasing order of string

  - * cmp() can‘t be static, so it should be put out of the solution class.

 

[007] 373. Find K Pairs with Smallest Sums (heap - C++)

  - Description: https://leetcode.com/problems/find-k-pairs-with-smallest-sums/

  - Submission Time + Difficulty: 1, 3 (1 ~ 10)

  - use priority_queue or custom sort

 

 

2020/06/12 

[008] 451. Sort Characters By Frequency (HashMap - Java)

  - Description: https://leetcode.com/problems/sort-characters-by-frequency/

  - Submission Time + Difficulty: 1, 2 (1 ~ 10)

  - brute force

 

[009] 739. Daily Temperatures (Stack - Java)

  - Description: https://leetcode.com/problems/daily-temperatures/

  - Submission Time + Difficulty: 1, 4 (1 ~ 10)

  - search from the beginning to the end. Use a stack to maintain all indices which we don‘t find answers and store them in the increasing order.

 

[010] 21. Merge Two Sorted Lists (LinkedList - Java)

  - Description: https://leetcode.com/problems/merge-two-sorted-lists/

  - Submission Time + Difficulty: 2, 3 (1 ~ 10)

  - Be careful that the problem wants us to "merge two sorted linked lists", not two linked lists with random order.

 

[011] 445. Add Two Numbers II (LinkedList - Java)

  - Description: https://leetcode.com/problems/add-two-numbers-ii/

  - Submission Time + Difficulty: 2, 3 (1 ~ 10)

  - Not only should we select the longer length as the size of ans array, to avoid size extended, we should also initialize a1 and a2 array using the longer length.

 

 

2020/06/13 

[012] 226. Invert Binary Tree (BinaryTree - Java)

  - Description: https://leetcode.com/problems/invert-binary-tree/

  - Submission Time + Difficulty: 1, 1 (1 ~ 10)

  - Simple recursion

 

[013] 101. Symmetric Tree (BinaryTree, Queue - Java)

  - Description: https://leetcode.com/problems/symmetric-tree/

  - Submission Time + Difficulty: 3, 4 (1 ~ 10)

  - BFS (queue). Should care about when root is null.

  - Initialize a queue using Java: Queue<TreeNode> q = new LinkedList<>();

 

[014] 554. Brick Wall (HashTable - Java)

  - Description: https://leetcode.com/problems/brick-wall/

  - Submission Time + Difficulty: 1, 3 (1 ~ 10)

  - prefix summation

leetcode - summer2020

原文:https://www.cnblogs.com/didyxdi/p/13123580.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!