Minimum depth of binary tree

Minimum depth of binary tree Title: Minimum depth of binary tree "Programmer code interview guide" question 33 P100 difficulty: original question ★☆☆☆ advanced question ★★★★ There are ordinary solutions and advanced solutions in this problem book. The advanced solution uses the divine method of traversing the binary tree - Morris trav ...

Added by helpmeplease1234 on Mon, 17 Jan 2022 22:58:50 +0200

leetcode question brushing / hash table 438 Find all alphabetic words in the string

438. Find all letter words in the string Meaning: Given two strings S and p, find the substrings of all ectopic words of p in s, and return the starting indexes of these substrings. The order in which answers are output is not considered. Ectopic words refer to strings with the same letters but arranged differently. Example 1: input: ...

Added by landonmkelsey on Mon, 17 Jan 2022 21:24:11 +0200

First practice of Euclidean algorithm

Title Source: Blue Bridge Cup-2017 Xiao Ming eats breakfast at a bun shop almost every morning. This bun is paved with N kinds of steaming cages, of which the second type just fits Ai buns Each type of steamer has many cages, which can be considered infinite. Whenever a customer wants to buy X buns, the uncle sells buns and chooses sever ...

Added by alanrenouf on Mon, 17 Jan 2022 16:50:55 +0200

Algorithm exercise: adding two numbers

Add two numbers Give you two non empty linked lists to represent two non negative integers. They store each number in reverse order, and each node can store only one number. Please add the two numbers and return a linked list representing sum in the same form. You can assume that neither number starts with 0 except the number 0. Example 1: Inp ...

Added by OttoBufonto on Mon, 17 Jan 2022 14:05:27 +0200

Reflected Penguin

Title Description You are given two integer arrays nums1 and nums2 in non decreasing order, and two integers m and n representing the number of elements in nums1 and nums2 respectively. Please merge nums2 into nums1 so that the merged array is also arranged in non decreasing order. Title Example Example 1: Input: nums1 = [1,2,3,0,0,0], ...

Added by brandtj on Mon, 17 Jan 2022 11:22:23 +0200

Linked list, single linked list, two-way (one-way) circular linked list

dynamic chain Single linked list: //Head node refers to the first node in the linked list, which can be divided into real head node and virtual head node; (1) Real head node: the first node is used to store data (usually the real head node is used). (2) Virtual head node: the first node cannot store data. (3) Header pointer: it is just a ref ...

Added by ataylor20 on Mon, 17 Jan 2022 07:54:50 +0200

c++ sort() function and its application

sort() function: it is a sort function in c++ stl library. Learning to use this function can greatly save us from writing a sort function, such as bubble sort (O(n2)). Moreover, this sort function is written by quick sort, so the time complexity is O(nlogn), so it can also greatly reduce the program running time. Note that the sorting range is ...

Added by diondev on Mon, 17 Jan 2022 06:52:35 +0200

Data structure - linear table notes

Linear table Definition and characteristics of linear table A linear table is a finite sequence of data elements with the same characteristics. Linear list: an ordered sequence composed of n (n > = 0) data elements (nodes) a1,a1,... An. definition: 1. The number n of data elements is defined as the length of the table. 2. When n=0, it ...

Added by zrueda on Mon, 17 Jan 2022 06:36:54 +0200

4. n queen problem

▲ in graph theory, there are two ways of traversing trees: breadth first traversal and depth first traversal Breadth first traversal (BFS): starting from an un traversed node of the graph, traverse the adjacent nodes of the node first, and then traverse the adjacent nodes of each adjacent node in turn (i.e. traversal layer by layer) For example ...

Added by New Coder on Mon, 17 Jan 2022 04:53:27 +0200

DFS thought and examples

The so-called Brute force is to list all possible situations, and then check them one by one to find the answer. This method is simple, direct, does not play tricks, and makes use of the powerful computing power of the computer. Violence laws are often synonymous with "inefficiency". However, compared with other "efficient&quot ...

Added by nyk on Mon, 17 Jan 2022 03:43:03 +0200