[Leetcode] 105. Constructing Binary Trees from Pre-order and Medium-order Traversal Sequences

Title Description Given a tree, preorder and inorder are traversed sequentially. Please construct a binary tree and return its root node. Example 1 Input: preorder = [3,9,20,15,7], inorder=[9,3,15,20,7] output:[3,9,20,null,null,15,7] Example 2 Input: preorder=[-1], inorder=[-1] output: [-1] Tips ...

Added by tHud on Wed, 26 Jan 2022 22:50:59 +0200

Week2 of monthly LeetCode weekly questions

catalogue 31. Next arrangement 32. Longest valid bracket 34. Find the first and last position of an element in a sorted array 33. Search rotation sort array 46. Full arrangement 39. Combination sum 77. Portfolio 78. Subset 48. Rotate image 49. Grouping of acronyms 56. Consolidation interval 62. Different paths 75. Color classificat ...

Added by towerspl on Wed, 26 Jan 2022 16:18:31 +0200

Sword finger Offer 57 And are two numbers of s

Sword finger Offer 57 And two numbers with s - LeetCode (LeetCode CN. Com) catalogue Scheme 1: basic method thinking Complexity code Operation results   Scheme 2: improvement of basic method thinking Complexity code Operation results Scheme 3: binary search thinking Complexity code Operation results Option 4: from both sid ...

Added by renegade33 on Wed, 26 Jan 2022 15:48:56 +0200

[algorithm exercise] LeetCode - dynamic programming learning plan

The title comes from: https://leetcode-cn.com/study-plan/dynamic-programming/?progress=nc4eyhc Climbing stairs (simple) class Solution { public int climbStairs(int n) { if (n <= 2 ) { return n; } int[] ans = new int[n + 1]; ans[1] = 1; ans[2] = 2; for (int i = 3; i <= n; ...

Added by phuggett on Wed, 26 Jan 2022 09:59:19 +0200

LeetCode-241 question - C language implementation

1. Original title [Title Source: LeetCode question 241] given a string containing numbers and operators, add parentheses to the expression and change its operation priority to get different results. You need to give the results of all possible combinations. Valid operation symbols include +, - and *. If the given string is 2 + 1-1 and there ar ...

Added by soto134 on Wed, 26 Jan 2022 08:51:00 +0200

Dynamic Planning Theme (Three Examples: Simple, Medium, Medium)

Example 1: Continuous series (simple interview question 16.17) Title link: Force bucklehttps://leetcode-cn.com/problems/contiguous-sequence-lcci/ Title: Given an array of integers, find the largest continuous sequence of sums and return the sum. Example: Input: [-2, 1, -3, 4, -1, 2, 1, -5, 4] Output: 6 Interpretation: The sum of cons ...

Added by excl209 on Wed, 26 Jan 2022 08:24:32 +0200

week10_task_ Joint search set diagram

10, Joint search set source Geek time 2021 algorithm training camp Author: Li Yudong 1. Merge query set Join query set is a tree data structure, which is used to deal with the merging and query of some disjoint sets. The idea of parallel search set is to use an array to represent the whole forest (parent). The root node of t ...

Added by big_al on Wed, 26 Jan 2022 03:42:41 +0200

0019 - delete the penultimate node of the linked list

Problem description Give you a linked list, delete the penultimate node of the linked list, and return the head node of the linked list. Advanced: can you try using one scan? Example 1: Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] Example 2: Input: head = [1], n = 1 Output: [] Example 3: Input: head = [1,2], n = 1 Output: [1] ...

Added by Namadoor on Tue, 25 Jan 2022 21:03:40 +0200

The maximum value of the queue and the maximum value of the sliding window

Title Description Given an array num and the size k of the sliding window, please find the maximum value in all sliding windows. Example: Input: nums = [1,3,-1,-3,5,3,6,7], and k = 3 Output: [3,3,5,5,6,7] Explanation: Position {maximum value of sliding window ---------------               ----- [1  3  -1] -3  5  3  6  7       3  1 [3  -1  - ...

Added by numan82 on Tue, 25 Jan 2022 18:45:53 +0200

LeetCode Day5 [data structure] intersection 2 of two arrays, best opportunity for trading stocks

350 Intersection of Two Arrays II intersection of two arrays 2 subject attempt First attempt: class Solution { public int[] intersect(int[] nums1, int[] nums2) { Arrays.sort(nums1); Arrays.sort(nums2); int[] nums3 = new int[nums1.length + nums2.length]; int size = 0; for( int i = 0; i < num ...

Added by phice on Tue, 25 Jan 2022 18:41:44 +0200