Leetcode question set 13 (remove elements)

Removing elements from an array in O(N) time usually uses a two fingered needle method. 27. Remove element  Give you an array nums   And a value Val, you need to remove all values in place equal to   val   And returns the new length of the array after removal. Instead of using extra array space, you must use only O(1) ex ...

Posted by Izzy1979 on Mon, 08 Nov 2021 23:07:23 -0800

Analysis of leetcode problem solving ideas 839 - 845 questions

Similar string Give you a list of strings strs. Each string in the list is an alphabetic word for all other strings in strs. How many similar string groups are there in strs? Using the idea of joint search set, the string array is transformed into a graph to find the connected edge class Solution { public: vector<int> f; int fi ...

Posted by sonicfusion on Mon, 08 Nov 2021 13:02:00 -0800

LeetCode 2065. Maximize the path value in a graph

Here's an undirected picture for you   Figure with n   Nodes, node number from 0   To n - 1   (both included). And give you a subscript from 0   Starting integer array   values  , among   values[i]   It's number I   Value of nodes  . And give you a subscript from 0   Starting 2D inte ...

Posted by pixelsoul on Mon, 08 Nov 2021 12:43:36 -0800

leetcode299 - brush the question file every day

You are playing balls and cows with your friends. The rules of the game are as follows: Write a secret number and ask your friend to guess what the number is. Every time a friend guesses, you will give him a hint containing the following information: Guess how many digits in the number belong to the number and the exact position (called &quot ...

Posted by stenk on Mon, 08 Nov 2021 12:41:16 -0800

299. Number guessing game

You are playing balls and cows with your friends. The rules of the game are as follows: Write a secret number and ask your friend to guess what the number is. Every time a friend guesses, you will give him a hint containing the following information: Guess how many digits in the number belong to the number and the exact position (called "B ...

Posted by rbastien on Sun, 07 Nov 2021 20:40:09 -0800

Implementation of leetcode breadth first search code framework

Implementation of leetcode BFS code framework Learning experience: There is such a sentence in the algorithm sketch. The operation of binary tree can derive a lot of algorithm ideas. More and more questions are brushed, and more and more experience will be gainedThere are also two forms of binary tree traversal, DFS and BFS. DFS includes thre ...

Posted by michaelphipps on Fri, 05 Nov 2021 16:01:57 -0700

String matching in algorithm

28 implementation str () Determines whether a string is a substring of another string and returns its position. Enter a parent string and a substring, and output an integer indicating the position of the substring in the parent string. If it does not exist, return - 1. Input: haystack = "hello", need = "ll" Output: 2 ...

Posted by jlpulido on Thu, 04 Nov 2021 21:04:14 -0700

[LeetCode stack and queue]: Classic OJ questions about stack and queue (implemented in C language and explained in detail with attached drawings)

1. Bracket matching problem LeetCode link: [20. Valid brackets] This problem is a classic example of using stack to solve problems; The idea is as follows: Traverse the string. If it meets the inverted left parenthesis, it will be put on the stack. If it meets the inverted right parenthesis, it will take the element at the top of the stac ...

Posted by skicrud on Thu, 04 Nov 2021 11:34:40 -0700

Find the k-th largest number of two ordered arrays

Title: give two one-dimensional int arrays a and B. where: A is an ordered array with length m and elements in good order from small to large. B is an ordered array with length n and elements arranged from small to large. We hope to find the maximum k numbers from the A and B arrays. It is required to use as few comparisons as possible. Soluti ...

Posted by ossi69 on Wed, 03 Nov 2021 22:27:41 -0700

LeetCode daily question -- receiving rainwater (November 3, 2021)

The topics are as follows: Give you a matrix of m x n, where the values are non negative integers, representing the height of each cell in the two-dimensional height map. Please calculate the maximum volume of rainwater that can be received by the shape in the map. Input: hightmap = [[1,4,3,1,3,2], [3,2,1,3,2,4], [2,3,3,2,3,1]] Output: 4 Expla ...

Posted by bobcooper on Wed, 03 Nov 2021 22:15:37 -0700