Skip to content
Home » two pointers

two pointers

Lintcode 1375 Substring With At Least K Distinct Characters

https://www.lintcode.com/problem/1375 Example 1: Example 2: This problem can also use the two pointers method we talked about in https://leetcode-solution.com/leetcode-209-minimum-size-subarray-sum-2/ with time complexity of O(n) The idea is the same, iterate the left pointer, at each iteration, find the right pointer… Read More »Lintcode 1375 Substring With At Least K Distinct Characters

Leetcode 167 Two Sum II – Input Array Is Sorted

Problem Statement Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1 <= index1 < index2 <= numbers.length. Return the indices of the two numbers, index1 and index2, added by… Read More »Leetcode 167 Two Sum II – Input Array Is Sorted