[code Capriccio] Chapter 10 greedy algorithm

Chapter 10 greedy algorithm Greed has no fixed template routine If we can find out the local optimum and deduce the global optimum, it is greedy; If the local optimum is not found, it is not greedy, but may be a simple simulation. Greedy algorithm is generally divided into the following four steps: The problem is decomposed into several sub ...

Posted by aaaaCHoooo on Mon, 21 Feb 2022 09:23:53 +0100

[force buckle question type summary and template] sword finger offer 1 - array and string

Question type summary subjectsummarypracticekey wordFind in 2D arrayIn an n * m two-dimensional array, each row is sorted in ascending order from left to right, and each column is sorted in ascending order from top to bottom. Please complete an efficient function, input such a two-dimensional array and an integer, and judge whether the arr ...

Posted by cloudnyn3 on Mon, 21 Feb 2022 03:59:30 +0100

LeetCode algorithm problem 117 solution + joint search set

1, Topic retelling leetCode algorithm Title: https://leetcode-cn.com/problems/H6lPxb/ Briefly described as: 1. Provides an array of strings. There are letter ectopic words between the string elements of the array. For example, "aaabb" and "baaab"; That is, the letters that make up the string are the same, and the letters ap ...

Posted by kennethl on Sun, 20 Feb 2022 20:15:38 +0100

Leetcode's notes -- the combinatorial problem of backtracking algorithm

Catalogue of series articles I Array type problem solving method 1: dichotomy II Array type problem solving method 2: Double finger needle method III Array type problem solving method 3: sliding window IV Array type problem solving method 4: simulation V The basic operation and classic topics of the linked list Vi Classic title of hash tab ...

Posted by Jack McSlay on Sun, 20 Feb 2022 18:27:37 +0100

717. 1-bit and 2-bit characters / 18 Sum of four / 22 bracket-generating

717. 1-bit and 2-bit characters [simple question] [daily question] Idea: Traverse the bits array from front to back. If the current element is 1, the second character, whether 10 or 11, starts with 1, so you can be sure that the current element and its next element form the second character, i+= 2 directly; The bits array has only 0 and 1. ...

Posted by simjay on Sun, 20 Feb 2022 16:52:06 +0100

[recent force buckle] word split + merge interval + linked list sorting + adjust the array order so that the odd number precedes the even number

Word splitting (medium) dynamic programming ”Whether leetcode "can be composed and decomposed into - whether" l "is stored in the dictionary and subsequent substrings can be composed when the step size is 1, etc; When the step size is 2, "le" is stored in the dictionary and subsequent substrings can be compose ...

Posted by shorty114 on Sun, 20 Feb 2022 04:15:26 +0100

Preliminary understanding pointer

1. What is the pointer 2. Pointer and pointer type 3. Field pointer 4. Pointer operation 5. Pointers and arrays 6. Secondary pointer 7. Pointer array 1. What is the pointer? What is the pointer? Two key points of pointer understanding:        1. A poi ...

Posted by TutorMe on Sun, 20 Feb 2022 02:41:17 +0100

leetcode-236. Nearest common ancestor of binary tree

leetcode-236. Nearest common ancestor of binary tree deque method class Solution { public: deque<TreeNode*> dqp; deque<TreeNode*> dqq; bool findNode(TreeNode* root, deque<TreeNode*>& dq, TreeNode* target) { dq.push_back(root); if(root == target) { return true; } bool ret = false; if(root->left) ...

Posted by BLINDGUY on Sat, 19 Feb 2022 13:48:41 +0100

Day86 sliding window maximum

Give you an integer array nums, with a sliding window of size k moving from the leftmost side of the array to the rightmost side of the array. You can only see k numbers in the sliding window. The sliding window moves only one bit to the right at a time. Returns the maximum value in the sliding window https://leetcode-cn.com/problems/sliding-w ...

Posted by jokeruk on Sat, 19 Feb 2022 08:43:14 +0100

LeetCode-004 Median of Two Sorted Arrays

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2. Solution 1 To find the median in an ordered array, you ...

Posted by theorok on Sat, 19 Feb 2022 05:09:39 +0100