Binary tree series

Single valued binary tree If each node of a binary tree has the same value, the binary tree is a single valued binary tree. true is returned only when the given tree is a single valued binary tree; Otherwise, false is returned. Example 1: Input: [1,1,1,1, null, 1] Output: true Example 2: Input: [2,2,2,5,2] Output: false link /** * Definition ...

Added by dpsd on Sun, 19 Dec 2021 05:16:10 +0200

LeetCode 169. Most elements (hash table)

subject Given an array of size n, find most of its elements. Most elements refer to elements that appear more than ⌊ n/2 ⌋ in the array. You can assume that the array is non empty and that there are always many elements in a given array. Example 1: Input:[3,2,3] Output: 3 Example 2: Input:[2,2,1,1,1,2,2] Output: 2 P ...

Added by johnnyk on Sat, 18 Dec 2021 00:46:15 +0200

Reverse linked list problem

1 recursively reverse the entire linked list For recursive algorithms, the most important thing is to clarify the definition of recursive functions. Specifically, our reverse function is defined as follows: Enter a node head,take「with head As the starting point」The linked list of is inverted and returns the head node after inversion. Und ...

Added by stickynote427 on Sat, 18 Dec 2021 00:39:12 +0200

(Maximum Subarray) maximum suborder sum

Title: Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Given an integer array nums, find a continuous sub array with the largest sum (the sub array contains at least one element) and return its maximum sum. E ...

Added by andreiga on Fri, 17 Dec 2021 23:39:15 +0200

Rotate Array

1. Title Give you an array and rotate the elements of the array K positions to the right, where k is a non-negative number. Example 1: Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4] Explanation: Rotate one step to the right: [7,1,2,3,4,5,6] Rotate 2 steps to the right: [6,7,1,2,3,4,5] Rotate 3 steps to the ri ...

Added by NightCoder on Thu, 16 Dec 2021 23:48:37 +0200

LeetCode algorithm learning notes - Day4

Java circular linked list Give you a head node of the linked list to judge whether there are links in the linked list.Returns true if there are links in the linked list. Otherwise, false is returned. LeetCode's friends use the fast and slow double pointer writing method to judge... I don't think it's necessary. It's a little inefficient Let's ...

Added by ruzztec on Thu, 16 Dec 2021 01:04:56 +0200

Ten thousand words long text | ten basic sorting, done at one time!

✨ Algorithm series recommended: LeetCode clearance: I heard that the linked list is the threshold, so I raised my foot and crossed the doorInterview brush algorithm, these APIs can not be known!LeetCode clearance: array seventeen, really not simpleLeetCode clearance: Brush 39 binary trees, crazy! Hello, I'm the third, a programmer who can' ...

Added by Louis-Platt on Wed, 15 Dec 2021 13:25:12 +0200

Data structure -- LeetCode special exercise Day13

 290. Word rules Given a pattern and a string str, judge whether str follows the same rule. The , here refers to complete matching. For example, there is a corresponding law of two-way connection between each letter in pattern , and each non empty word in string , str ,. Example 1: Input: pattern = "Abba", STR = "dog cat ...

Added by fellow21 on Wed, 15 Dec 2021 01:23:26 +0200

The fourth day of nine day training

First question The integer array nums is arranged in ascending order, and the values in the array are different from each other. Before passing to the function, Num rotates on a previously unknown subscript k (0 < = k < num.length), making the array [num [k], Num [K + 1],..., Num [n-1], Num [0], Num [1],..., Num [k-1]] (subscripts count ...

Added by vcv on Sun, 12 Dec 2021 14:44:56 +0200

[problem solving report] series of lecture 100 on zero basis of algorithm (Lecture 2)

☘ preface ☘ Today is the second day of the zero basis clock out of the algorithm. Today's problem is deadly -. -. Link on: Series of lecture 100 on the basis of zero algorithm (Lecture 2) 🧑🏻 About the author: a young man who changed from industrial design to embedded ✨ Contact: 2201891280(QQ) ⏳ Approximate reading time of the full te ...

Added by cloudnyn3 on Sat, 11 Dec 2021 15:57:10 +0200