[LeetCode] 1034. Coloring A Border

Given a 2-dimensional grid of integers, each value in the grid represents the color of the grid square at that location. Two squares belong to the same connected component if and only if they have the same color and are next to each other in any of the 4 directions. The border of a connected component is all the squares in the connected compon ...

Posted by peterg012 on Mon, 18 Apr 2022 02:18:38 +0300

leetcode -- evaluation of inverse Polish expression

1, Problem description Find the value of the expression according to the inverse Polish representation. Valid operators include +, -, *, /. Each operand can be an integer or another inverse Polish expression. Note: integer division only retains the integer part; The given inverse Polish expression is always valid. In other words, an expressio ...

Posted by gatoruss on Sun, 17 Apr 2022 17:47:56 +0300

Leetcode-480 Sliding window median

Sliding window median The median is the number in the middle of the ordered sequence. If the length of the sequence is even, there is no middle number; At this time, the median is the average of the two numbers in the middle. For example: [2,3,4], the median is 3[2,3], the median is (2 + 3) / 2 = 2.5 Give you an array nums, with a window of ...

Posted by ready2drum on Sun, 17 Apr 2022 12:46:56 +0300

LeetCode question 14: longest common prefix (java)

Title: longest common prefix Write a function to find the longest common prefix in the string array. If there is no public prefix, the empty string '' is returned. Example: Input: strs = ["flower","flow","flight"] Output:"fl" Input: strs = ["dog","racecar","car"] Output:"" Explanation: the input does not have a public prefix. Topic inter ...

Posted by jfs0479 on Sun, 17 Apr 2022 09:21:35 +0300

Acwing number range - bisection algorithm - java implementation

Dichotomy algorithm The binary algorithm is divided into integer binary and floating-point binary. Floating-point binary is easier I Original question link Given an array of integers of length n in ascending order and q queries. For each query, the start and end positions of an element k are returned (the positions are counted from 0). I ...

Posted by jerbecca on Sat, 16 Apr 2022 17:56:37 +0300

Fussiness Algorithms (Swordfinger Series) - Practice 4.15 per day

2022.4.15 Swordfinger Offer 06. Print chain list from end to end Simple difficulty Enter the head node of a list of chains and return the value of each node (in an array) from the end to the end. Ideas: Create an array, traverse the array upside down, and follow the list of chains to reverse the effect. (wastes space) With arraylist, ...

Posted by Bit343 on Fri, 15 Apr 2022 20:00:53 +0300

[Leetcode] 2 questions: thoroughly understand stacks and queues

preface 🎬 OK, I specifically learned the knowledge of stack and queue. Then the main content of this blog is to do three OJ questions. After learning, we must brush the questions in time to deepen our understanding and consolidation. Otherwise, it is difficult to make progress, which is conducive to our better learning of stack and queue of ...

Posted by PHP_TRY_HARD on Fri, 15 Apr 2022 03:00:49 +0300

LeetCode daily question 1178 Guessing crossword puzzles

1178. Crossword puzzles A foreign friend has designed an English version of a crossword puzzle game based on Chinese crossword puzzles. Please guess. The puzzle of a word puzzle is given in the form of a string. If a word word meets the following two conditions, it can be counted as the answer: The word word word contains the first letter of ...

Posted by olivarespablo on Fri, 15 Apr 2022 02:49:09 +0300

Subsequence problem of dynamic programming

Subsequence problem is a common algorithm problem. Subsequence problem itself is more difficult than substring and subarray, because the former is a discontinuous sequence, and the latter two are continuous. Even exhaustive is not easy, let alone solving relevant algorithm problems. The subsequence problem is likely to involve two strings. For ...

Posted by Scooby08 on Thu, 14 Apr 2022 09:58:09 +0300

[LeetCode] sword finger Offer Chapter IV ⊰⊰⊰ questions 32 - 38

[LeetCode] sword finger Offer Chapter IV ⊰⊰⊰ questions 32 - 38 32-Ⅰ. Print a binary tree (medium) from top to bottom Sword finger Offer 32 - I. print binary tree from top to bottom [title] print each node of the binary tree from top to bottom, and the nodes of the same layer are printed from left to right. [example] Given binary tree: ...

Posted by jefkin on Thu, 14 Apr 2022 07:51:10 +0300