Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/LeetCode/Biweekly Contest 181/3911. K-th Smallest Remaining Even Integer in Subarray Queries
Prev
LeetCodeLeetCode
Advanced
Biweekly Contest 181

3911. K-th Smallest Remaining Even Integer in Subarray Queries

Prefix SumArrayBinary Search
Loading...
Solve on LeetCode

Problem Statement

Official algorithmic problem description and constraints.

Open on LeetCode

You are given an integer array nums where nums is strictly increasing.


You are also given a 2D integer array queries, where queries[i] = [li, ri, ki].

For each query [li, ri, ki]:

  • Consider the subarray nums[li..ri]
  • From the infinite sequence of all positive even integers: 2, 4, 6, 8, 10, 12, 14, ...
  • Remove all elements that appear in the subarray nums[li..ri].
  • Find the kith smallest integer remaining in the sequence after the removals.

Return an integer array ans, where ans[i] is the result for the ith query.

A subarray is a contiguous non-empty sequence of elements within an array.

An array is said to be strictly increasing if each element is strictly greater than its previous one (if exists).

 

Example 1:

Input: nums = [1,4,7], queries = [[0,2,1],[1,1,2],[0,0,3]]

Output: [2,6,6]

Explanation:

iqueries[i]nums[li..ri]Removed

EvensRemaining

Evenskians[i]0[0, 2, 1][1, 4, 7][4]2, 6, 8, ...121[1, 1, 2][4][4]2, 6, 8, ...262[0, 0, 3][1][]2, 4, 6, ...36

Thus, ans = [2, 6, 6].

Example 2:

Input: nums = [2,5,8], queries = [[0,1,2],[1,2,1],[0,2,4]]

Output: [6,2,12]

Explanation:

iqueries[i]nums[li..ri]Removed

EvensRemaining

Evenskians[i]0[0, 1, 2][2, 5][2]4, 6, 8, ...261[1, 2, 1][5, 8][8]2, 4, 6, ...122[0, 2, 4][2, 5, 8][2, 8]4, 6, 10, 12, ...412

Thus, ans = [6, 2, 12].

Example 3:

Input: nums = [3,6], queries = [[0,1,1],[1,1,3]]

Output: [2,8]

Explanation:

iqueries[i]nums[li..ri]Removed

EvensRemaining

Evenskians[i]0[0, 1, 1][3, 6][6]2, 4, 8, ...121[1, 1, 3][6][6]2, 4, 8, ...38

Thus, ans = [2, 8].

 

Constraints:

  • 1 <= nums.length <= 105
  • 1 <= nums[i] <= 109
  • nums is strictly increasing
  • 1 <= queries.length <= 105
  • queries[i] = [li, ri, ki]
  • 0 <= li <= ri < nums.length
  • 1 <= ki <= 109​​​​​​​


Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Biweekly Contest 181
Previous Problem