摘要:
I n this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that started as a tree with n nodes labeled 阅读全文
随笔档案-2021年07月
[LeetCode]348. Design Tic-Tac-Toe_Medium tag: array
2021-07-30 00:41 by Johnson_强生仔仔, 33 阅读, 收藏, 编辑
摘要:
Assume the following rules are for the tic-tac-toe game on an n x n board between two players: A move is guaranteed to be valid and is placed on an em 阅读全文
[LeetCode] 895. Maximum Frequency Stack_Hard tag: stack
2021-07-29 23:17 by Johnson_强生仔仔, 23 阅读, 收藏, 编辑
摘要:
Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: Freq 阅读全文
[LeetCode] 428. Serialize and Deserialize N-ary Tree_hard tag: DFS, Divide and Conquer
2021-07-29 22:39 by Johnson_强生仔仔, 48 阅读, 收藏, 编辑
摘要:
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or 阅读全文
[LeetCode] 297. Serialize and Deserialize Binary Tree_hard tag: DFS, Divide and Conquer
2021-07-29 22:03 by Johnson_强生仔仔, 11 阅读, 收藏, 编辑
摘要:
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or 阅读全文
[LeetCode] 957. Prison Cells After N Days_Medium Tag: Array
2021-07-29 10:54 by Johnson_强生仔仔, 33 阅读, 收藏, 编辑
摘要:
There are 8 prison cells in a row and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to th 阅读全文
[LeetCode] 763. Partition Labels_Medium Tag: sort
2021-07-29 08:50 by Johnson_强生仔仔, 25 阅读, 收藏, 编辑
摘要:
763. Partition Labels Medium 5066206Add to ListShare You are given a string s. We want to partition the string into as many parts as possible so that 阅读全文
[LeetCode] 253. Meeting Rooms II_Medium tag: Heap
2021-07-29 08:14 by Johnson_强生仔仔, 53 阅读, 收藏, 编辑
摘要:
Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required. Exampl 阅读全文
[LeetCode] 252. Meeting Rooms_Easy tag: Sort
2021-07-29 07:24 by Johnson_强生仔仔, 13 阅读, 收藏, 编辑
摘要:
Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings. Example 1: Input: inter 阅读全文
[LeetCode] 973. K Closest Points to Origin_Medium tag: Sort, heap, quickSort
2021-07-29 07:10 by Johnson_强生仔仔, 36 阅读, 收藏, 编辑
摘要:
Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0 阅读全文
[LeetCode] 56. Merge Intervals_Medium Tag: sort
2021-07-29 06:43 by Johnson_强生仔仔, 26 阅读, 收藏, 编辑
摘要:
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals 阅读全文
[Leetcode] 543. Diameter of Binary Tree_Easy Tag: DFS
2021-07-29 05:51 by Johnson_强生仔仔, 7 阅读, 收藏, 编辑
摘要:
Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwee 阅读全文
[LeetCode] 25. Reverse Nodes in k-Group_Hard tag: Linked List
2021-07-29 04:33 by Johnson_强生仔仔, 13 阅读, 收藏, 编辑
摘要:
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to 阅读全文
[LeetCode] 5. Longest Palindromic Substring _Medium tag: Two pointers
2021-07-29 00:38 by Johnson_强生仔仔, 11 阅读, 收藏, 编辑
摘要:
Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer. Examp 阅读全文
[LeetCode] 79. Word Search_Medium tag: Backtracking, DFS
2021-07-28 11:04 by Johnson_强生仔仔, 43 阅读, 收藏, 编辑
摘要:
Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequent 阅读全文
[LeetCode]2. Add Two Numbers_Medium tag: Linked List
2021-07-27 22:00 by Johnson_强生仔仔, 11 阅读, 收藏, 编辑
摘要:
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes conta 阅读全文
[LeetCode] 77. Combinations_Medium tag: backtracking
2021-07-14 10:18 by Johnson_强生仔仔, 18 阅读, 收藏, 编辑
摘要:
Given two integers n and k, return all possible combinations of k numbers out of the range [1, n]. You may return the answer in any order. Example 1: 阅读全文