Heard that reverse thinking can reduce time complexity?

Starting with the end means setting goals first and then making plans in daily life. I learned this concept when I read management books before.In the algorithm, taking the end as the beginning refers to pushing back from the result to the initial state of the problem.So when is it appropriate to think in reverse? A very simple principle is:The ...

Posted by sitestem on Fri, 28 Jan 2022 19:22:38 +0100

A Leecode every day - find the median of two positive arrays and share with Tencent high-frequency interview questions!

Find the median of two positively ordered arrays Method 1: binary search Given two ordered arrays, it is required to find the median of two ordered arrays. The most intuitive ideas are as follows: Using the merging method, merge two ordered arrays to get a large ordered array. The element in the middle of a large ordered array is the median. ...

Posted by moonshaden on Fri, 28 Jan 2022 17:59:01 +0100

Take you hand in hand to disassemble the LRU algorithm

Take you hand in hand to disassemble the LRU algorithm summary LRU algorithm is a cache elimination strategy. The principle is not difficult, but it is more skilled to write bug free algorithms in the interview. It needs to abstract and disassemble the data structure layer by layer. labuladong in this paper will write you beautiful code. ...

Posted by lakshmiyb on Fri, 28 Jan 2022 15:25:20 +0100

2021-06-21 repeating elements in ordered linked list 2

leetcode daily question of deleting duplicate elements in the sorting linked list Title Link: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/submissions/ Title Description: There is a linked list arranged in ascending order. Give you the head node of the linked list. Please delete all nodes with duplicate numbers in t ...

Posted by DavidT on Fri, 28 Jan 2022 00:39:54 +0100

2045. Second short time to destination

Difficulty: difficulty catalogue 1, Problem description 2, Problem solving thought 3, Problem solving 1. Judge extreme situations 2. Code implementation 4, Summary 1, Problem description The problem description above LeetCode is directly used here. Cities are represented by a two-way connected graph, in which there are n nodes, numbe ...

Posted by habs20 on Thu, 27 Jan 2022 23:53:54 +0100

Sword finger Offer-Day74(C++) 38 Arrangement of strings

Sword finger Offer 38 Arrangement of strings Enter a string and print out all the arrangements of characters in the string. You can return this string array in any order, but there can be no duplicate elements in it. Example: Enter: s = "abc" Output: ["abc", "acb", "bac", "bca", "cab&quo ...

Posted by boombanguk on Thu, 27 Jan 2022 22:47:55 +0100

LeetCode 23. Merging K Ascending Chain Lists & Merging Ordered Chain Lists

Title Requirements Link to the original title: 23. Merge K Ascending Chain Lists The Title requirements are as follows: Give you an array of lists, each in ascending order. Please merge all lists into one ascending list and return the merged list. Examples are as follows: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] ...

Posted by kesmithjr on Thu, 27 Jan 2022 19:54:38 +0100

[python life from scratch ②] improvement method of Likou crawler

☘ preface ☘ What can you learn after reading this blog? Reading and writing methods of excel How to get the interface Multithreading improves crawler efficiency Cloud server deployment web service real-time update In this blog, based on the previous article, I will further explore the website interface api to improve the access speed, fur ...

Posted by Sekka on Thu, 27 Jan 2022 18:12:01 +0100

Leetcode problem solving series -- symmetric binary tree (recursion)

This topic aims to share some interesting or valuable topics found in the process of brushing Leecode. [answer based on js, of course].Recursive algorithm has always been one of the key types of leetcode medium difficulty exercises, so the key is self-evident.Topic relatedOriginal address: https://leetcode-cn.com/problems/dui-cheng-de-er-cha-sh ...

Posted by godwisam on Thu, 27 Jan 2022 15:12:33 +0100

LeetCode[4]: find the median of two positively ordered arrays

Give two positively ordered (from small to large) arrays nums1 and nums2 of sizes m and n, respectively. Please find and return the median of these two positive arrays. The time complexity of the algorithm should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merge array = [1,2,3], median 2 Exam ...

Posted by mrgrinch12 on Thu, 27 Jan 2022 08:45:01 +0100