Day04 array of ahan sword finger offer

catalogue array 1 number of duplicates found 1. hashmap save times   two   Arrays.stream sorting directly query adjacent duplicate 3. set storage (problem solving)   4. Use array index! array 1 number of duplicates found 1. hashmap save times   Use map.get() to determine whether there is one. In fact, you can ou ...

Posted by mickro on Sat, 06 Nov 2021 13:33:31 +0100

LeetCode - problem solving notes - 109 - 0109. Convert Sorted List to Binary Search Tree

Solution 1 The question is 0108. Convert Sorted Array to Binary Search Tree It is possible to directly use the divide and conquer tree idea of finding the middle position as the root node in the previous question, which is to solve the method of determining the middle position in the linked list. [refer to the official] the method to find the ...

Posted by webmasternovis on Tue, 02 Nov 2021 14:09:00 +0100

Leetcode 18. Sum of four numbers -- learning notes

Title: Force bucklehttps://leetcode-cn.com/problems/4sum/ class Solution { public List<List<Integer>> fourSum(int[] nums, int target) { List<List<Integer>> ans = new ArrayList<>(); Arrays.sort(nums); int l; int r; for(int index1=0;index1<nums.length-3;index1++){ ...

Posted by nafetski on Sun, 31 Oct 2021 09:22:06 +0100

Summary of 2021-10-22 Brushing Titles

Catalog Summary of Today's Brush Topics Single-valued binary tree (easy) The same tree (easy) Prime number calculation position (easy) in binary representation Number (mid)II that occurs only once supplement Summary of Today's Brush Topics Single-valued binary tree (easy) Title link: 965.Single Value Binary Tree-Force Button (leetco ...

Posted by stlewis on Thu, 21 Oct 2021 19:19:21 +0200

All algorithms for breadth and depth traversal of binary tree

All algorithms for breadth and depth traversal of binary tree For the traversal of binary tree, there are two categories: breadth traversal and depth traversal. For depth traversal, it is divided into first order, middle order and second order. These three first, middle and second order can be written by recursive and non recursive algorithms. ...

Posted by iMiles on Thu, 21 Oct 2021 09:42:09 +0200

The solution and application of the addition of two numbers in three minutes - algorithmic practice

💂 Personal homepage: IT learning diary🤟 Copyright: This article was originally written by [IT learning diary] and launched in CSDN. If you need to reprint IT, please contact the blogger💬 If the article is helpful to you, welcome to follow, like, collect (one click, three links) and subscribe to the column💅 To find a small partner ...

Posted by guitarlvr on Wed, 20 Oct 2021 02:47:30 +0200

leetcode Solving Thought Analysis 825 - 831 Questions

Friends of appropriate age People send friend requests to each other. Now given an array containing their age, ages[i] indicates the age of the ith person. When either of the following conditions is met, A cannot send friend requests to B (A, B are not the same person): age[B] <= 0.5 * age[A] + 7 age[B] > age[A] age[B] > 100 && ...

Posted by _Alex_ on Sat, 16 Oct 2021 19:04:16 +0200

Several ways of writing dichotomy

It integrates several writing methods on Li buckle and the writing method of code Capriccio. Thank you! Key points: define the interval clearly and keep it unchanged in the loop operation (loop invariant principle). 1, Number of binary search monotone arrays (no repetition) 1. Left closed right closed int binarySearch(vector<int> &amp ...

Posted by tomz0r on Thu, 30 Sep 2021 23:29:17 +0200

Sword finger offer java day30 divide and conquer algorithm

T1 17. Print from 1 to the maximum n digits leetcode returns int [] without considering the large number. The original book considers the case that the large number is out of bounds Large number out of bounds is not considered class Solution { public int[] printNumbers(int n) { int m = (int)Math.pow(10,n)-1; //Number of prints to ...

Posted by grimmier on Thu, 30 Sep 2021 21:58:43 +0200

[leetcode SQL] game play analysis Ⅰ - Ⅳ

First, give the Activity table used by the four questions: +--------------+---------+ | Column Name | Type | +--------------+---------+ | player_id | int | | device_id | int | | event_date | date | | games_played | int | +--------------+---------+ The primary key of the table is (player_id, event_date). This table s ...

Posted by NerdConcepts on Wed, 29 Sep 2021 21:56:00 +0200