3 posts about Two Pointers by 2 contributors.
Know Two Pointers? Share what you know with developers who are learning it.
Given an even-sized integer array, divide the array into two equal halves. A pair (i, j) is considered a dominant pair if i belongs to the first half, j belongs to the second half, and arr[i] >= 5 × arr[j]. The goal is to count the total number of dominant pairs efficiently. A brute-force approach takes O(n²) time. By sorting both halves independently and using the two-pointer technique, we can solve the problem in O(n log n) time. This problem is a good example of how sorting can optimize pair-counting problems by avoiding unnecessary comparisons.
Maximize thieves caught by policemen within distance 'k' using a greedy two-pointer approach. Optimal O(n) solution ensures the closest valid pairs are matched first.
Learn how to solve the 3SUM problem in C# using sorting and the two-pointer technique to find unique triplets that sum to zero.
DevSocialUpcoming · 3rd editionAI Agents ConferenceNov 23–27, 2026Live onlineMembers only16days leftRegisterPublish an article in this category and earn +1,000 SHARP when it is approved.
Write an article