[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of "combined sum III"

1, Title Requirements Find all combinations of k numbers whose sum is n. only positive integers of 1 - 9 are allowed in the combination, and there are no duplicate numbers in each combination.explain: All numbers are positive integers. The solution set cannot contain duplicate combinations. Example 1: input: k = 3, n = 7 output: [[1,2 ...

Posted by phonydream on Mon, 10 Jan 2022 11:39:37 +0100

Leetcode---2. Add two numbers (linked list)

Give you two non empty linked lists to represent two non negative integers. They store each number in reverse order, and each node can store only one number. Please add the two numbers and return a linked list representing sum in the same form. You can assume that neither number starts with 0 except the number 0. Input: l1 = [2,4,3], l2 = [5, ...

Posted by st3ady on Mon, 10 Jan 2022 06:32:50 +0100

Sword finger Offer 35 Replication of complex linked list (java implementation, in-situ modification solution)

Let's start with: Please implement the copyRandomList function to copy a complex linked list. In a complex linked list, each node has a next pointer to the next node and a random pointer to any node or null in the linked list. Example 1: Input: head = [[7, null], [13, 0], [11, 4], [10, 2], [1, 0]] Output: [7, null], [13, 0], [11, 4 ...

Posted by numtre on Sun, 09 Jan 2022 23:07:07 +0100

The 19th day of working hard to become a programmer

Today, I was oncall again. Although things are simple, dealing with people's emotions really affects their mood. Adjust the negative emotions, calm down to listen to the class and brush the questions. Speaking about double pointers today, the idea and implementation are relatively simple. Study notes: 1.167. Sum of two II - input ordered arra ...

Posted by ConcreteDJ on Sun, 09 Jan 2022 15:58:46 +0100

LeetCode 5978. Count the number of words that can be obtained by adding letters (bit operation + hash)

1. Title Give you two string arrays with subscripts starting from 0, startWords and targetWords. Each string consists of only lowercase English letters. For each string in targetWords, check whether a string can be selected from startWords, perform a conversion operation, and the result is equal to the current targetWords string. The con ...

Posted by eits on Sun, 09 Jan 2022 15:16:12 +0100

Data structure -- sequential table (array) topic

Array of related interview questions Click to enter > > Remove element (LeetCode) Give you an array num and a value val. you need to remove all elements with a value equal to Val in place and return the new length of the removed array. Instead of using extra array space, you must use only O(1) extra space and modify the input arr ...

Posted by Valord on Sun, 09 Jan 2022 15:10:09 +0100

Summary of problem solutions for single week competition on January 9, 2022

T1 5976. Check whether each row and column contain all integers For a matrix of size n x n, if each row and column contains all integers from 1 to n (including 1 and N), the matrix is considered to be an effective matrix. Give you an integer matrix of size n x n, please judge whether the matrix is a valid matrix: If yes, return true; Otherwis ...

Posted by fcaserio on Sun, 09 Jan 2022 13:51:20 +0100

Is a shareholder of the company

Title Description You are given two integer arrays nums1 and nums2 in non decreasing order, and two integers m and n representing the number of elements in nums1 and nums2 respectively. Please merge nums2 into nums1 so that the merged array is also arranged in non decreasing order. Title Example Example 1: Input: nums1 = [1,2,3,0,0,0], ...

Posted by nschmutz on Sun, 09 Jan 2022 04:20:18 +0100

1182. Minimum distance from target color

1182. Minimum distance from target color Give you an array of colors, which has 1, 2 and 3 colors. We need to perform some queries on colors, where each item to be queried is composed of two integers i and c. Now please help design an algorithm to find the shortest distance from index i to the element with target color c. If no solution exi ...

Posted by yhchan on Sun, 09 Jan 2022 00:21:42 +0100

Summary of leetCode binary search methods

This article explores some of the most common dichotomy scenarios: finding a number, finding the left boundary, and finding the right boundary. Moreover, we just want to go into the details, such as whether the unequal sign should be equal, whether the mid should be added, and so on. In the form of question and answer, analyze the differences ...

Posted by siminder on Sat, 08 Jan 2022 18:44:32 +0100