Double pointer algorithm - sum of two numbers II

Give you an integer array numbers with subscript starting from 1. The array has been arranged in non decreasing order. Please find two numbers in the array that meet the sum of addition and equal to the target number target. If the two numbers are numbers[index1] and numbers[index2] respectively, then 1 < = index1 < index2 < = numbers ...

Posted by Hobgoblin11 on Fri, 11 Feb 2022 10:01:40 +0100

[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of "deleting duplicates in ordered arrays"

1, Title Requirements Give you an ordered array nums, please delete the repeated elements in place, make each element appear only once, and return the new length of the deleted array.Do not use additional array space. You must modify the input array in place and complete it with O(1) additional space.explain: Why is the returned value an in ...

Posted by priya_amb on Tue, 25 Jan 2022 05:27:06 +0100

The interviewer asked me to go back and look at the first question.

⭐ Introduction ⭐ Neodymium Hi everyone, I'm stuck. Today we are explaining the series of classical sums. It's good to say that some people can't do the first thing while watching the sea at night. You should all know that the first question of power button is the sum of two numbers. But in fact, the sum of two numbers is only the beginning. In ...

Posted by greatepier on Thu, 30 Dec 2021 23:03:46 +0100

Sliding window -- double pointer idea with the same direction

The general idea is as follows: Given a sequence, define two pointers left and right, and define the measurement index F before the interval [left,right], such as interval sum, product and others according to the meaning of the question. At the beginning, left=right=0, calculate the index F. left remains unchanged first, right moves to the rig ...

Posted by sidney on Mon, 20 Dec 2021 23:26:00 +0100

LeetCode brush notes double pointer sliding window

sliding window Sliding window: if two pointers point to the same linear table, the traversal direction is the same, and the starting points of the two pointers are different, a sliding window will be formed. The two pointers move with different strategies until the values of the two pointers are equal or meet other special conditions. 76 mini ...

Posted by yoda69 on Sun, 05 Dec 2021 06:37:06 +0100

Double pointer algorithm

preface After listening to one of the basic algorithm classes held by yxc in acwing and listening to the double pointer algorithm, I feel that in fact it is still a violent method, but after analysis, it is actually an O(n) algorithm. I can't help but be a little curious. At the beginning, I didn't understand it. I always feel that it still has ...

Posted by pacome on Sat, 04 Dec 2021 22:44:41 +0100