KEMBAR78
STL Level 3 DPP 01 Discussion Notes | PDF | Pointer (Computer Programming) | Algorithms
0% found this document useful (0 votes)
14 views13 pages

STL Level 3 DPP 01 Discussion Notes

The document discusses various algorithmic problems and their solutions using C++ with a focus on data structures and algorithms. Key topics include the Two Pointer Approach for finding pairs that sum to a target, maximum subarray sums, and counting subarrays with specific properties. Additional problems addressed include finding the next greater element in a circular array and determining the minimum number of railway platforms needed.

Uploaded by

sachin55443gg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views13 pages

STL Level 3 DPP 01 Discussion Notes

The document discusses various algorithmic problems and their solutions using C++ with a focus on data structures and algorithms. Key topics include the Two Pointer Approach for finding pairs that sum to a target, maximum subarray sums, and counting subarrays with specific properties. Additional problems addressed include finding the next greater element in a circular array and determining the minimum number of railway platforms needed.

Uploaded by

sachin55443gg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

CS & IT

ENGINEERING
C++ WITH OOPS

STL Level - 3

DPP 01 Discussion Notes By- Aditya sir


Recap of Previous Lecture

Topic DPP Questions Discussion


Stack
soon
Two Pointer Approach-1: Pair Sum in Sorted Array

Problem Statement:
Given a sorted array, find two numbers that sum up to a given target
Example 1:
Input: nums = [1,2,3,4,6], target = 6
Output: [1,3] (indexes)
Example 2:
Input: nums = [2,3,7,11], target = 9
Output: [0,2]
Two Pointer Approach-1: Pair Sum in Sorted Array

Solution Explanation:
• Use two pointers: one starts at the beginning and one at the end.
• If the sum of both numbers is equal to target, return their indices.
• If the sum is smaller, move the left pointer to the right.
• If the sum is greater, move the right pointer to the left.
Maximum Subarray with At Most One Deletion

Problem Statement:
Given an array nums, find the max sum of a contiguous subarray allowing at most
one deletion.
Example 1:
Input: nums = [1,-2,0,3]
Output: 4
Next Greater Element in Circular Array

Problem Statement:
Find the next greater element for each element in a circular array.
Example 1:
Input: nums = [1,2,1]
Output: [2,-1,2]
Number of Subarrays with Sum K

Problem Statement:
Given an array nums, count the number of subarrays whose sum equals k.
Example 1:
Input: nums = [1,1,1], k = 2
Output: 2
Smallest Window Containing All Characters of Another String

Problem Statement:
Find the minimum window substring in s that contains all characters of t.
Example 1:
Input: s = "ADOBECODEBANC", t = "ABC"
Output: "BANC"
Largest Rectangle in Histogram

Problem Statement:
Find the largest rectangular area in a histogram.
Example 1:
Input: heights = [2,1,5,6,2,3]
Output: 10
Minimum Number of Platforms

Problem Statement:
Find the minimum number of railway platforms needed given train arrival and
departure times.
Example 1:
Input: arrival = [900, 940, 950, 1100, 1500, 1800],
departure = [910, 1200, 1120, 1130, 1900, 2000]
Output: 3
Count Subarrays with Product Less Than K

Problem Statement:
Given an array, find the number of contiguous subarrays with a product < k.
Example 1:
Input: nums = [10, 5, 2, 6], k = 100
Output: 8
Maximum Sum of K Consecutive Elements

Problem Statement:
Given an array, find the maximum sum of any k consecutive elements.
Example 1:
Input: nums = [2, 3, 5, 1, 6, 2, 7], k = 3
Output: 15
THANK - YOU

You might also like