Deep search (DFS) questions
catalogue
1, Foreword
2, Title Description
① Students who want to practice English can read this question carefully to see if they can understand the question. What do you want us to do!
② The following is the input and output of the sample (read the question carefully! There is an implication)
3, Topic interpretation
4, Train of thoug ...
Posted by jateeq on Tue, 04 Jan 2022 14:00:50 +0100
20210805 summary of force deduction string questions
Daily question 611: judge whether it is a triangle
My inherent impression is to use violence to solve, then timeout, and then sort the array and recalculate. It is passed, but it takes too long.
class Solution {
public int triangleNumber(int[] nums) {
int n = nums.length;
if(n<3) return 0;
int count = 0;
...
Posted by glence on Tue, 04 Jan 2022 13:15:57 +0100
Solution to the 273rd weekly game of Leetcode
Solution to the 273rd weekly game of Leetcode (C + + version)
Problem A - Number reversed twice
meaning of the title Ask whether a number reversed twice is equal to the original number thinking Only the last 0 matches the number 0 code
class Solution {
public:
bool isSameAfterReversals(int num) {
return (num%10||num==0);
}
}; ...
Posted by ginger76 on Tue, 04 Jan 2022 11:24:11 +0100
leetcode brush questions / daily questions 116 Populates the next right node pointer for each node
116. Populate the next right node pointer for each node
Meaning:
Given a perfect binary tree, all leaf nodes are in the same layer, and each parent node has two child nodes. Binary tree is defined as follows:
struct Node {
int val;
Node *left;
Node *right;
Node *next;
}
Fill in each of its next pointers so that this pointer po ...
Posted by moonie on Tue, 04 Jan 2022 10:31:10 +0100
Understanding of dijestra algorithm and its proof by counter proof method
Understanding of dijestra algorithm
Today, do a single source longest path problem leetcode-743 , although I immediately thought of dijestra algorithm, I became a little vague about its specific idea, so I reviewed this classic algorithm with this problem.
Overview of dijestra algorithm Dijkstra algorithm was proposed by Dutch computer scient ...
Posted by XtacY on Tue, 04 Jan 2022 08:59:09 +0100
LeetCode-416. Split equal sum subset
Topic source
416. Segmentation and subsets
Title details
Give you a non empty array containing only positive integers, {nums. Please judge whether this array can be divided into two subsets so that the sum of the elements in the two subsets is equal.
Example 1:
Input: num = [1,5,11,5]
Output: true
Explanation: an array can be divided into [1, 5 ...
Posted by mattcass on Tue, 04 Jan 2022 08:12:18 +0100
[daily force deduction 15] effective letter words
1, Title [LeetCode-242]
Given two strings s and t, write a function to determine whether t is an alphabetic ectopic word of s.
Note: if each character in , s and t , occurs the same number of times, then , s and t , are called alphabetic words.
Example 1:
Input: s = "anagram", t = "nagaram"
Output: true
Exa ...
Posted by sebjlan on Tue, 04 Jan 2022 02:50:46 +0100
[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of "stone game VI"
1, Title Requirements
Alice and Bob play a game in turn. Alice takes the lead. There are n stones in a pile of stones. When it's a player's turn, he can remove a stone and get the value of the stone. Alice and Bob have different criteria for the value of stones. Both sides know each other's criteria.Give you two integer arrays of length n, ali ...
Posted by yuan22m on Mon, 03 Jan 2022 22:42:33 +0100
LeetCode - #10 regular expression matching (top 100)
preface
This topic is the top 100 high frequency questions of LeetCode
Our community will gradually organize the Swift Algorithm Solutions of Gu Yi (Netflix growth hacker, author of iOS interview, ACE professional fitness coach. Microblog: @ Taoist Gu Yin) into text versions to facilitate everyone's learning and reading.
So far, we have upda ...
Posted by cohq82 on Mon, 03 Jan 2022 22:09:40 +0100
Binary search [template + use question type + exercise]
▄█▔▉●
Bisection template
Template 1
int BinarySearch1(vector<int>& nums, int target) {
int l = 0, r = nums.size() - 1;
while (l <= r) {//
int mid = l + (r - l) / 2;
if (nums[mid] == target) {//
return mid;
} else if (nums[mid] > target) {
r = mid - 1;
} else {
l = mid + 1;
}
}
return -1;
}
Templat ...
Posted by gigya on Mon, 03 Jan 2022 16:02:20 +0100