摘要:Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head. The steps of the insertion sort algorit 阅读全文
[LeetCode] 147. Insertion Sort List_Middle tag: Linked List
2023-10-22 04:12 by Johnson_强生仔仔, 5 阅读, 0 推荐, 收藏, 编辑Data structure - Sort & quick sort 小结及leetcode相关题目
2023-10-21 02:48 by Johnson_强生仔仔, 41 阅读, 0 推荐, 收藏, 编辑
摘要:Sort 主要有以下几种常见的sort, 面试中最有可能考的是quick sort, 关于k largest or 什么相关的。 Bubble sort Insertion sort Merge sort Quicksort Selection sort Counting sort Bucket s 阅读全文
[LeetCode] 2863. Maximum Length of Semi-Decreasing Subarrays_Medium tag: stack
2023-10-12 04:56 by Johnson_强生仔仔, 160 阅读, 0 推荐, 收藏, 编辑
摘要:You are given an integer array nums. Return the length of the longest semi-decreasing subarray of nums, and 0 if there are no such subarrays. A subarr 阅读全文
[LeetCode] 2434. Using a Robot to Print the Lexicographically Smallest String_Medium tag: stack
2023-10-12 02:28 by Johnson_强生仔仔, 3 阅读, 0 推荐, 收藏, 编辑
摘要:You are given a string s and a robot that currently holds an empty string t. Apply one of the following operations until s and t are both empty: Remov 阅读全文
[LeetCode] 2282. Number of People That Can Be Seen in a Grid_Medium tag: stack.
2023-10-11 05:59 by Johnson_强生仔仔, 12 阅读, 0 推荐, 收藏, 编辑
摘要:You are given an m x n 0-indexed 2D array of positive integers heights where heights[i][j] is the height of the person standing at position (i, j). A 阅读全文
[LeetCode] 1944. Number of Visible People in a Queue_Hard tag: stack
2023-10-11 05:27 by Johnson_强生仔仔, 10 阅读, 0 推荐, 收藏, 编辑
摘要:There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers 阅读全文
Data structure - Stack 小结及leetcode相关题目
2023-10-11 05:26 by Johnson_强生仔仔, 17 阅读, 0 推荐, 收藏, 编辑
摘要:Linear data structure - Stack O(1) for push O(1) for pop O(1) for top - Basic skills 先进后出 [LeetCode] 232. Implement Queue using Stacks_Easy tag: stack 阅读全文
[LeetCode] 2334. Subarray With Elements Greater Than Varying Threshold_Hard tag: dp, stack
2023-09-29 00:18 by Johnson_强生仔仔, 16 阅读, 0 推荐, 收藏, 编辑
摘要:You are given an integer array nums and an integer threshold. Find any subarray of nums of length k such that every element in the subarray is greater 阅读全文
[LeetCode] 85. Maximal Rectangle_Hard tag: Dynamic Programming
2023-09-14 08:26 by Johnson_强生仔仔, 5 阅读, 0 推荐, 收藏, 编辑
摘要:Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matri 阅读全文
[LeetCode] 382. Linked List Random Node_Medium tag: linked list, math
2021-08-23 04:36 by Johnson_强生仔仔, 29 阅读, 0 推荐, 收藏, 编辑
摘要:Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Implement the 阅读全文