Computer Network Object Oriented
Programming
Operating System Data Structures
& Algorithms
Linux DataBase
Management
System

Computer Network

Reference Links :

https://www.geeksforgeeks.org/computer-network-tutorials/
https://youtube.com/playlist?list=PLBlnK6fEyqRgMCUAG0XRw78UA8qnv6jEx
https://takeuforward.org/computer-network/most-asked-computer-networks-interview-questions/

Object Oriented Programming

Reference Links :

https://youtu.be/wN0x9eZLix4
https://www.geeksforgeeks.org/object-oriented-programming-in-cpp/
https://youtube.com/playlist?list=PL43pGnjiVwgTJg7uz8KUGdXRdGKE0W_jN
https://drive.google.com/file/d/1sBHIi91iT9MbpLNj8LVLPn9AyO13wMUG/view?usp=sharing

Operating System

Reference Links :

https://www.geeksforgeeks.org/operating-systems/
https://youtube.com/playlist?list=PLBlnK6fEyqRiVhbXDGLXDk_OQAeuVcp2O
https://takeuforward.org/operating-system/most-asked-operating-system-interview-questions/

Linux

Reference Links :

https://www.geeksforgeeks.org/linux-commands/
https://youtu.be/ZtqBQ68cfJc

1. whoami
-- returns the UserName

2. man
-- manual, man whoami = gives the description of whoami

3. clear
-- clear terminal, clear -x scrolls down

4. pwd
-- displays present working directory

5. ls
-- displays list of files in that folder

6. cd
-- change directory, cd /Desktop/aoight, cd ../.. , cd ~/

7. mkdir
-- make directory, creates folder, mkdir xyz, mkdir mutliple folders

8. touch
-- creates a empty .txt file, if file is already present file will be opened in write mode.

9. rmdir
-- removes directory (folder) only if it is empty

10. rm
-- remove files

11. open
-- open filename, open foldername

12. mv
-- move / rename , mv exp.pdf Exp.pdf (rename) , mv exp.pdf fold/ (move exp into fold folder)

13. cp
-- copy, cp ex.pdf EX.pdf (in the directory EX.pdf is created which is a copy of ex.pdf)

14. head
-- first lines, head ex.pdf -n 10 (first 10 lines of EX.pdf)

15. tail
-- last lines, tail ex.pdf -n 10 (last 10 lines of EX.pdf)

16. date
-- displays current date time

17. redircting ouptut
-- date > text.txt (overrides text), date >> text.txt (appends text)

18. cat
-- cat f1 f2 (displays f1.txt + f2.txt)

19. echo
-- echo "hi"( print hi in terminal), echo "hi" > text.txt, echo "hi" >> text.txt

20. sort
-- sort text.txt

21. uniq
-- removes same adjacent values

22. find
-- (find -name 'te'), (find -name '*t*' = find file which contains t in it)

23. du
-- finds the disk usage , storage used ( du exFolder )

24. df
-- disk free space available

25. history
-- previous commands, (history | less)- few history ,(history | exam) - history commands which included exam

26. ps
-- proccess, display what programmes are running

27. top
-- display process and update sorted information

28. gzip
-- (gzip -k file) creates zip version of file

29. gunzip
-- (gunzip file.gz) unzips compressedfile

DataBase Managment System

Reference Links :

https://youtu.be/5OdVJbNCSso
https://youtu.be/nWeW3sCmD2k
https://youtu.be/p3qvj9hO_Bo
https://youtu.be/HXV3zeQKqGY
https://www.geeksforgeeks.org/dbms/
https://youtube.com/playlist?list=PLBlnK6fEyqRiyryTrbKHX1Sh9luYI0dhX
https://takeuforward.org/interviews/must-do-questions-for-dbms-cn-os-interviews-sde-core-sheet/
SQL -> Structured Query Language
sql is case insensitive language i.e Create == CREATE
creating a dataBase :
-- single line comments
CREATE DATABASE ;
USE ;
Delete dataBase :
DROP DATABASE ;
Alter is a keyword used when we want to modify database structure or constraints.
-- means we can't modify / delete the dataBase
alter database read only = ;
create a table :
create table (
INT , -- represents one column in a table
varchar (50) ,
varchar (50) ,
decimal (5,2) , -- 5 interger, 2 decimal places
date -- " yyyy - mm - dd "
);
select a table, which will print or display it.
select from ; -- * means all
select from ; -- we can select custom columns
select id, first_name, phone_no from employees, contacts
WHERE employees.id = contacts.emp_id ;
-- we can select custom columns
rename or drop the table
rename table to ;
drop table ;
add another column to the table / delte column
alter table add varchar(50) ;
alter table drop column ;
rename the column name, modify the column.
alter table rename column to ;
alter table modify column ;
change the order of columns
alter table modify first ;
-- email column will be 1st column in table.
alter table modify after ;
-- email column will be kept after first_name column in table.
insert data / entity / row into table.
insert into values
( ) ;
insert multiple rows into table.
insert into values ( ) , ( ) , ( ) ;
insert partial data into table.
insert into ( ) values ( );
WHERE, select data with a condition check.
select from where ;
update column values.
update set ;
-- this will make hourly_pay of all employees = 6
update set
where ;
-- this will change only hourly_pay and hire_date of employee with id = 7
delete row
delete from ; -- this will delete whole table
delete from where ;
-- whole row with employee id = 7 is deleted
Generally if we modify the table, we can't undo the action
but with keeping auto commit off we can undo the action.
set autocommit = off ;
-- assume we made some modifications to table ...
commit -- this is a safe point, changes upto now are saved
-- some another modifications , if we want to undo these actions
rollback ; -- modifications removed, back to latest safe point
date , time , now
create table (
date ,
time ,
date ,
);
insert into values ( current_date() , current_time(), now() );
-- " 2023 - 06 - 04 " , " 07:19:56 " , " 2023 - 06 - 04 07:19:56 "
unique constraint while creating table
create table (
varchar(25) unique , -- no two products should have same name
decimal(4,2)
);
unique constraint to already created table
alter table add constraint unique ( product_name ) ;
Null is Invalid constraint while creating table
create table (
varchar(25) unique ,
decimal(4,2) not null -- null / empty values are not accepted.
);
Null is Invalid constraint to already created table
alter table modify decimal(4, 2) not null ;
check attribute constraint while creating table
create table (
INT ,
varchar (50) ,
decimal (5,2) ,
check()
);
create table (
INT ,
varchar (50) ,
decimal (5,2) ,
constraint check()-- giving name to constraint
);
check constraint to already created table.
alter table add constraint check();
alter table drop check ; -- remove constraint
default data while creating table
create table (
varchar(25) unique ,
decimal(4,2) default 0.1
-- if price is not given while inserting data by default it will take 0.1

);
default data to already created table.
alter table alter set default 0.1 ;
primary key,
A table should have only one primary key
create table (
int primary_key ,
decimal( 4, 2 ) default 0
);
create table (
int,
decimal( 4, 2 ) default 0 ,
primary key( trans_id )
);
add primary key to already created table.
alter table add constraint primary_key( ) ;
Auto Increment
create table (
int NOT NULL auto_increment,
decimal( 4, 2 ) default 0
);
ALTER TABLE transactions auto_incerment = 50
-- this will start auto numbers from 50
alter table auto_incerment = ;
Foreign Key - to establish link btw Two tables
set foreign_key_checks = 0 ;
create table (
int primary_key ,
decimal(4,2) default 0
int , foreign key () references employees( );
-- emp_id in transaction table referece's to employee_id in employees table
);
alter table drop foregin key ;
alter table
add constraint ( )
foreign key ( ) references employees( );
Joins
select from inner join
on transactions.emp_id = employees.employee_id ;
-- output will be table of
trans_id -> amount -> emp_id -> employee details from employees table

-- INNER JOIN => table on transcations which have proper employee id
-- LEFT JOIN => table all transcations, if emp_id is proper followed employee details
-- RIGHT JOIN => table all customers, if emp_id is proper followed transaction details
Functions
select count( from transactions ;
-- COUNT(*) will give count of total number of rows in the query
select count( from Customers GROUP BY City ;
-- MAX( amount )
-- AVG( amount )
select CONCAT(as from transactions ;
select CAST(as int64) from transactions ;
-- cast() means changes the data type of coloumn
select UPPERCASE(first_name), Lowercase( last_name) from transactions ;
select INITCAP(first_name) from transactions ;
-- init cap means first letter of each word will be uppercase select SUBSTRING(as from transactions ;
-- SUBSTRING(name, x, y) means substring of name starting from index x and of length y
select REPLACE( from transactions ;

Few more functions, CHAR_LENGTH() or LENGTH(), TRIM('character' FROM "string"),
REVERSE("string"), CONCAT_WS('seperator','word1','word2',...)
REPEAT("string",count), RTRIM("string","groups of characters you want to remove") -- removes trailing characters
SPACE(7), STRCMP("string1", "string2") -- Compare Two Strings
NOW(), CURDATE(), CURTIME(), DATE(sales_date) -- extract only date
EXTRACT(YEAR FROM sale_date), DATE_ADD(sale_date, INTERVAL 7 DAY)
DATE_SUB(sale_date, INTERVAL 3 DAY), DATEDIFF(date1, sale_date)
DATE_FORMAT(sale_date, '%W, %M %d, %Y')
COALESCE(value1, value2) -> if value1 is null then value2 is given as output
where and
-- AND
-- NOT
-- IN
where in ( " " , " " , " " )
Wild Cards
select from
where like -- s% = s + anyString
-- s_ = s + anyOneChar
Order BY
select from
order by ; -- asc

select from
order by desc;
Limit
select from
order by LIMIT ; -- first two row's will be displayed
select from
order by LIMIT ;
-- after odering after 3rd record i.e from 4th row 5 records will be displayed.
select from
order by LIMIT OFFSET 5 ;
-- offset is same as skip; so first 5 records will skip and next 2 records will appear
CASE
select
CASE
WHEN age >= 65 THEN "SENIOR"
WHEN age < 18 THEN "MINOR"
ELSE "Adult"
END AS "Category"
from ;
Union
select from
union
select from ;
-- union removes duplicate records, we can use "UNION ALL" if we want duplicates
select from
union all
select from ;
-- we can give null if we dont have anything to equalize the no of columns
Self Join
alter table add INT ;
select from As inner join customers as
on a.referal_id b.customer_id ;
-- table have id , name , referal_id
-- one user may be referal to another use, inner join helps to visualize it
View
create view employee_sheet as select
from ;
-- employee sheet is not another table it is a custom view of employee table
-- changes in first_name, last_name of employee table will also effect employee_sheet .
Distinct
select distinct from ;
Sub Queries
select
( select avg() from employees ) from ;
Group By
select sum( ), from transactions group by
order_date - total amount on this order_date
select sum( ), from transactions group by
having count( ) > 1 and is not null ;
order_date - total amount on this order_date
Roll Up
select sum( ), from transactions group by
with roll up ;
-- total sum added as another row
Window Functions
select
SUM ( ) , over(partition by department order by salary ) AS runnig_total
from employees ;

Row_Number()
ROW_NUMBER() Over( partition by department order by salary ) AS row_no ;
ROW_NUMBER() Over( order by salary ) AS row_no ;
ROW_NUMBER() Over( order by (select null)) AS row_no ;

RANK()
RANK() Over( partition by department order by salary desc ) AS salary_rank ;
-- emp with same salary will get same rank, next rank will be skipped, use DENSE_RANK() to make no int is skipped

NTILE( x )
NTILE(5) Over( order by salary desc ) AS salary_rank ;
-- after sorting by salary, whole data set is divided into 5 equalize parts and salary_rank is given as 1,2,3,4,5

LEAD( col_name, offset, default_value)
LEAD(salary, 2, 0) Over( order by salary desc ) AS nxt_row_salary ;
-- after sorting by salary, for each nth row in nxt_row_salary column the (n+2)th row salary displays

LAG( col_name, offset, default_value)
LAG(salary, 2, 0) Over( order by salary desc ) AS nxt_row_salary ;
-- after sorting by salary, for each nth row in nxt_row_salary column the (n-2)th row salary displays

referece resource
CTE - Common Table Expresion
WITH RankedEmployees AS (
select Name, department, salary,
RANK() OVER(PARTITION BY department ORDER BY salary DESC ) AS Emp_rank
FROM Employees
)
SELECT * FROM RankedEmployees WHERE Emp_rank <= 3
-- select should be right after with() statement
On Delete
create table (
int primary_key ,
decimal(4,2) default 0
int , foreign key () references employees()
on delete set null ;
);
-- on delete set null = on breaking foreign key relation, the value is kept as null
-- on delete set cascade = on breaking foreign key relation, the whole row is deleted
Triggers
create trigger
before update on
for each row
set new.( new.) ;
-- assume we made a change SET hourly_pay = 50,
-- before updating hourly_pay, salary will change to new.horuly_pay * 2800
-- before insert, before update, before delete
-- after insert, after update, after delete

DataStructures & Algorithms

Reference Links :

https://takeuforward.org/strivers-a2z-dsa-course/strivers-a2z-dsa-course-sheet-2/
https://www.geeksforgeeks.org/dsa-sheet-by-love-babbar/
https://takeuforward.org/interviews/strivers-sde-sheet-top-coding-interview-problems/
https://www.geeksforgeeks.org/fundamentals-of-algorithms/?ref=shm
https://practice.geeksforgeeks.org/explore
https://leetcode.com/problemset/all/
https://neetcode.io/

Baiscs :

https://youtu.be/EAR7De6Goz4

C++ STL

https://youtu.be/RRVYpIET_RU
https://drive.google.com/file/d/1SGClJuB_ZMXUmZyvHc-laxbonjKEH3nZ/view?usp=sharing

Time & Space Complexity

https://youtu.be/FPu9Uld7W-E

Pattern Problems

https://youtu.be/tNm_NNSB3_w

Math Problems

https://youtu.be/1xNbjMdbjug
Bubble Sort

Given an array of N integers, write a program to implement the Bubble sorting algorithm.

Question ID : 0106231625

Easy
sorting
Arrays

Problem : https://practice.geeksforgeeks.org/problems/bubble-sort/1

Solution : https://youtu.be/HGk_ypEuS24?t=1062

Hint : observe two adjacent elements and swap them if second one is smaller.
Selection Sort

Given an unsorted array of N integers, write a program to implement the Selection sorting algorithm.

Question ID : 0106231657

Easy
sorting
Arrays

Problem : https://practice.geeksforgeeks.org/problems/selection-sort/1

Solution : https://youtu.be/HGk_ypEuS24?t=167

Hint : if you are at index (i) swap it with minimum from i to last index
Insertion Sort

Given an unsorted array of N integers, write a program to implement the Insertion sorting algorithm.

Question ID : 0106231926

Easy
sorting
Arrays

Problem : https://practice.geeksforgeeks.org/problems/insertion-sort/0

Solution : https://youtu.be/HGk_ypEuS24?t=1899

Hint : For index(i) move it left until (i-1) is less than i, for i = 0 -> n
Merge Two Sorted Arrays

Given two sorted arrays A[] and B[] of size N and M. The task is to merge both the arrays into a single array in non-decreasing order.

Question ID : 0106231948

Easy
Arrays

Problem : https://www.interviewbit.com/blog/merge-two-sorted-arrays/

Hint : i = 0, j = 0, compare and add and move least index
Merge Sort

Given an array arr[], its starting position l and its ending position r. Sort the array using merge sort algorithm.

Question ID : 0106232013

Medium
ReVisit
Sorting
Recursion
Arrays

Problem : https://practice.geeksforgeeks.org/problems/merge-sort/1

Solution : https://youtu.be/ogjf7ORKfd8?t=75

Hint : Divide array and use merge two sorted arrays algorithm
Count Sort

Question ID : 0206230938

Easy
Sorting
Arrays

Problem : https://practice.geeksforgeeks.org/problems/counting-sort/1

Solution : https://youtu.be/7zuGmKfUt7s

Hint : conunt freq of all elements
Quick Sort

Given a unsorted array, sort is using divide, conquer, partition.

Question ID : 0206230954

Medium
ReVisit
Sorting
Arrays
Recursion

Problem : https://www.codingninjas.com/codestudio/problems/quick-sort_983625

Solution : https://youtu.be/WIrA4YexLRQ

Hint : Pick an element and place it in right position
Largest Element

Find the largest element in array

Question ID : 0206231026

Easy
Arrays

Problem : https://bit.ly/3Pld280

Solution : https://youtu.be/37E9ckMDdTk?t=522

Second Largest Element

Find the second largest element in array

Question ID : 0206231037

Easy
ReVisit
Arrays

Problem : https://bit.ly/3pFvBcN

Solution : https://youtu.be/37E9ckMDdTk?t=815

check sorted

Check whether the given array is sorted

Question ID : 0206231043

Easy
Arrays

Problem : https://practice.geeksforgeeks.org/problems/check-if-an-array-is-sorted0701/1

Solution : https://youtu.be/37E9ckMDdTk?t=1722

Hint : ele(i+1) should be greater than ele(i)
Remove Duplicates

Remove duplicates from sorted array

Question ID : 0206231053

Easy
ReVisit
Arrays

Problem : https://bit.ly/3w7b6ck

Solution : https://youtu.be/37E9ckMDdTk?t=1891

Hint : slow, fast pointer to be used
Left Rotate By 1

Given an array arr[] of size N, the task is to left rotate the array 1 index

Question ID : 0206231107

Easy
Arrays

Problem : https://bit.ly/3dnn9vC

Solution : https://youtu.be/wvcQg43_V8U?t=61

Hint : keep start element, move all elements one index left and place start element at the end
Quick Left Rotate

Given an array arr[] of size N, the task is to left rotate the array K indexes

Question ID : 0206231108

Easy
ReVisit
Arrays

Problem : https://bit.ly/3dnn9vC

Solution : https://youtu.be/wvcQg43_V8U?t=486

Hint : reverse(0,d) reverse(d,n) reverse(0,n)
Move Zeros to End

Given an array arr[] of N positive integers. Push all the zeros of the given array to the right end of the array while maitaining the order of non-zero elements.

Question ID : 0206231208

Easy
Arrays

Problem : https://bit.ly/3PrGIjT

Solution : https://youtu.be/wvcQg43_V8U?t=1633

Hint : slowPointer, fastPointer to be used
Searching an element in a sorted array

Given an array arr[] sorted in ascending order of size N and an integer K. Check if K is present in the array or not. If it is present return the index, or -1.

Question ID : 0206231216

Easy
Arrays

Problem : https://bit.ly/3KcpHcB

Solution : https://youtu.be/wvcQg43_V8U?t=2465

Hint : slowPointer, fastPointer to be used
Union of Two Arrays

Union of two arrays can be defined as the common and distinct elements in the two arrays.
Given two sorted arrays of size n and m respectively, find their union.

Question ID : 0206231224

Easy
Arrays

Problem : https://bit.ly/3Ap7Onp

Solution : https://youtu.be/wvcQg43_V8U?t=2584

Hint : like mergeing two sorted arrays
Intersection of Two Arrays

You are given two arrays 'A' and 'B' of size 'N' and 'M' respectively. Both these arrays are sorted in non-decreasing order. You have to find the intersection of these two arrays.
Intersection of two arrays is an array that consists of all the common elements occurring in both arrays.

Question ID : 0206231256

Easy
Arrays

Problem : http://bit.ly/3KSSx3Z

Solution : https://youtu.be/wvcQg43_V8U?t=3551

Hint : like mergeing two sorted arrays
Missing Number

Give a vector, interger n. Actually the vector should contain first n natural numbers, but unfortunately one number got missed, find out the missing number.

Question ID : 0206231351

Easy
Arrays

Problem : https://bit.ly/3A2pKTh

Solution : https://youtu.be/bYWLJb3vCWY?t=57

Hint : sum of 1st n natural numbers - sum of array
Max Consecutive 1 's

You are given an array ‘ARR’ of length ‘N’ consisting of only ‘0’s and ‘1’s. Your task is to determine the maximum length of the consecutive number of 1’s.

Question ID : 0206231359

Easy
Arrays

Problem : http://bit.ly/3ZFZji5

Solution : https://youtu.be/bYWLJb3vCWY?t=1123

Hint : maxL, L two variables.
Find the element that appears once.

Given a sorted array A[] of N positive integers having all the numbers occurring exactly twice, except for one number which will occur only once.
Find the number occurring only once.

Question ID : 0206231406

Easy
Arrays
ReVisit

Problem : https://bit.ly/3dudCD8

Solution : https://youtu.be/bYWLJb3vCWY?t=1370

Hint : XOR of array
Row with max 1 's

Given a boolean 2D array of n x m dimensions where each row is sorted. Find the 0-based index of the first row that has the maximum number of 1 's.

Question ID : 0206231421

Easy
Arrays

Problem : https://bit.ly/3QNDw2W

Hint : search column wise, starting with 0 col, 0 row go to 0 col n row, if you find 1 in i th row return i.
Longest Sub-Array with Sum K +

Given an array containing N positive integers and an integer K., Your task is to find the length of the longest Sub-Array with the sum of the elements equal to the given value K.

Question ID : 0206231429

Medium
ReVisit
Arrays

Problem : https://takeuforward.org/data-structure/longest-subarray-with-given-sum-k/

Solution : https://youtu.be/frf7qxiN2qU?t=162

Hint : two pointers (l, r), move r, if sum > k move l
Longest Sub-Array with Sum K + -

Given an array containing N positive + negative integers and an integer K., Your task is to find the length of the longest Sub-Array with the sum of the elements equal to the given value K.

Question ID : 0206231514

Medium
ReVisit
Arrays

Problem : https://bit.ly/3dyZdp3

Solution : https://takeuforward.org/arrays/longest-subarray-with-sum-k-postives-and-negatives/

Hint : map, reverse engineering
Find a pair with a given sum

Sam want to read exactly ‘TARGET’ number of pages. He has an array ‘BOOK’ containing the number of pages for ‘N’ books. Return YES/NO, if it is possible for him to read any 2 books and he can meet his ‘TARGET’ number of pages.

Question ID : 0206231748

Easy
Arrays

Problem : https://bit.ly/3SVYU8f

Solution : https://youtu.be/UXDSeD9mN-k?t=50

Hint : push element to map, search map for a pair
Majority Element

Given an array A of N elements. Find the majority element in the array. A majority element in an array A of size N is an element that appears more than N/2 times in the array.

Question ID : 0206231805

Medium
Arrays
ReVisit

Problem : https://bit.ly/3SSpeA3

Solution : https://youtu.be/nP_ns3uSh80?t=47

Hint : Moore's voting Algorithm
Max Sum SubArray

Given an array Arr[] of N integers. Find the contiguous sub-array(containing at least one number) which has the maximum sum and return its sum.

Question ID : 0206231823

Medium
Arrays

Problem : https://bit.ly/3dzyloY

Solution : https://youtu.be/w_KEocd__20

Hint : Kadane's Algorithm
Maximum sum of smallest and second smallest.

Given an array, find maximum sum of smallest and second smallest elements chosen from all possible sub-arrays. More formally, if we write all (nC2) sub-arrays of array of size >=2 and find the sum of smallest and second smallest, then our answer will be maximum sum among them.

Question ID : 0206231844

Easy
Arrays
Sliding Window

Problem : https://practice.geeksforgeeks.org/problems/max-sum-in-sub-arrays0824/0

Hint : sliding window, check max(vec[i]+vec[i+1])
Alternate positive and negative numbers

Given an unsorted array Arr of N positive and negative numbers. Your task is to create an array of alternate positive and negative numbers without changing the relative order of positive and negative numbers.
If any of the positive and negative numbers are completed. we will continue with the remaining signed elements

Question ID : 0206231858

Easy
Arrays

Problem : https://bit.ly/3Qr3sSs

Solution : https://youtu.be/h4aBagy4Uok?t=44

Hint : +ve at eve, -ve at odd
Next Permutaion

Implement the next permutation, which rearranges the list of numbers into Lexicographically next greater permutation of list of numbers. If such arrangement is not possible, it must be rearranged to the lowest possible order i.e. sorted in an ascending order. You are given an list of numbers arr[ ] of size N.

Question ID : 0206231912

Medium
Arrays
ReVisit

Problem : https://bit.ly/3dug78u

Solution : https://youtu.be/JDOXKqF60RQ?t=43

Hint : from last, elements should be increasing order
Leaders in an array

Given an array A of positive integers. Your task is to find the leaders in the array. An element of array is leader if it is greater than or equal to all the elements to its right side. The rightmost element is always a leader.

Question ID : 0206231948

Easy
Arrays

Problem : https://bit.ly/3bZqbGc

Solution : https://youtu.be/cHrH9CQ8pmY?t=39

Hint : max of array, start from end of array
Longest consecutive subsequence

Given an array of positive integers. Find the length of the longest sub-sequence such that elements in the subsequence are consecutive integers, the consecutive numbers can be in any order.

Question ID : 0206231958

Medium
Arrays

Problem : https://bit.ly/3ApytAD

Solution : https://youtu.be/oO5uLE7EUlM?t=52

Hint : make a set
Set Zero Matrix

You are given a matrix 'MATRIX' of dimension 'N' x 'M'. Your task is to make all the elements of row 'i' and column 'j' equal to 0 if any element in the ith row or jth column of the matrix is 0.

Question ID : 0206232012

Medium
ReVisit
Arrays

Problem : https://bit.ly/3CukQke

Solution : https://youtu.be/N0MgLvceX7M?t=51

Hint : use col0,row0 for marking.
Rotate Matrix By 90deg

Given a square matrix of size N x N. The task is to rotate it by 90 degrees in anti-clockwise direction without using any extra space.

Question ID : 0206232029

Medium
Arrays

Problem : https://bit.ly/3PqpeV8

Solution : https://youtu.be/Z0R2u6gd3GU?t=46

Hint : transpoe + mirror
Print In Sprial Manner

Question ID : 0206232038

Medium
Arrays

Problem : https://bit.ly/3ppEJ53

Solution : https://youtu.be/3Zv-s9UUrFM?t=40

Hint : keep boudnary on all sides
Pascal Triangle

Given a positive integer N, return the Nth row of pascal's triangle.
Pascal's triangle is a triangular array of the binomial coefficients formed by summing up the elements of previous row.

Question ID : 0306231018

Medium
Arrays

Problem : https://bit.ly/3C95qlR

Solution : https://youtu.be/bR7mQgwQ_o8?t=47

Hint : nCi = n-i/i+1
Three Sum

You are given an array ‘ARR’ containing ‘N’ integers.Return all the unique triplets [ARR[i], ARR[j], ARR[k]] such that i != j, j != k and k != i and their sum is equal to zero.

Question ID : 0306231053

Medium
Arrays

Problem : https://bit.ly/3X34JSI

Solution : https://youtu.be/DhFh8Kw7ymk?t=40

Hint : sort -> three pointers,one fixed for one iteration.
Four Sum

Given an array of integers and another number. Find all the unique quadruple from the given array that sums up to the given number.

Question ID : 0306231122

Hard
ReVisit
Arrays

Problem : https://bit.ly/3It5SyP

Solution : https://youtu.be/eD95WRfh81c?t=50

Hint : sort -> i, j fixed, l k two sum pointers
Largest subarray with 0 sum

Largest subarray with 0 sum

Question ID : 0306231152

Hard
ReVisit
Arrays

Problem : https://bit.ly/3w5QSzC

Solution : https://youtu.be/xmguZ6GbatA?t=11

Hint : prefixSum hashMap
Insert Node

Given head of a linkedList, create and insert a node at the end, begining of list.

Question ID : 0306231410

Linked List
Easy

Problem : https://bit.ly/3w9pEIt

Hint : temp = temp -> next, while temp -> next != null
Delete Node in Linked List

Given a singly linked list and an integer x.Delete x th node from the singly linked list.

Question ID : 0306231419

Easy
Linked List

Problem : https://bit.ly/3Apg5aX

Hint : store next of deleted item first.
Length of List

Given a singly linked list. The task is to find the length of the linked list, where length is defined as the number of nodes in the linked list.

Question ID : 0306231427

Easy
Linked List

Problem : https://bit.ly/3Po7tpf

Finding middle element in a linked list

Given a singly linked list of N nodes. The task is to find the middle of the linked list. For example, if the linked list is
1-> 2->3->4->5, then the middle node of the list is 3.
If there are two middle nodes(in case, when N is even), print the second middle element.

Question ID : 0306231433

Medium
ReVisit
Linked List

Problem : https://bit.ly/3dAjkn1

Solution : https://youtu.be/sGdwSH8RK-o?t=9

Hint : fastPointer = 2 * slowPoiner
Reverse Linked List

Given a linked list of N nodes. The task is to reverse this list.

Question ID : 0306231441

Easy
Linked List

Problem : https://bit.ly/3zY03mT

Solution : https://youtu.be/iRtLEoL-r-g?t=7

Hint : curr, prev
Detect Loop in linked list

Given a linked list of N nodes. The task is to check if the linked list has a loop. Linked list can contain self loop.

Question ID : 0606230746

Linked List
easy
ReVisit

Problem : https://bit.ly/3QN8PLn

Solution : https://youtu.be/354J83hX7RI

Hint : fastPointer, slowPointer when they meet cycle is there.
Starting node of Cycle

Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.

Question ID : 0606230759

Easy
Linked List

Problem : https://leetcode.com/problems/linked-list-cycle-ii/

Solution : https://youtu.be/QfbOhn0WZ88

Hint : fastPointer == slowPointer, start another pointer from head
Length of Loop

Given a linked list of size N. The task is to check whether a given Linked List contains a loop or not and if the loop is present then return the count of nodes in a loop or else return 0.

Question ID : 0606230838

Easy
Linked List

Problem : https://bit.ly/3dyXL6m

Hint : detect loop and continue
Check if Linked List is Palindrome

Given a singly linked list of size N of integers. The task is to check if the given linked list is palindrome or not.

Question ID : 0606230916

Medium
Linked List

Problem : https://bit.ly/3JVrnXJ

Solution : https://youtu.be/-DtNInqFUXs?t=22

Hint : find middle and reverse list.
Remove Nth Node From End of List

Given the head of a linked list, remove the nth node from the end of the list and return its head.

Question ID : 0606231002

Easy
Linked List

Problem : https://leetcode.com/problems/remove-nth-node-from-end-of-list/

Solution : https://youtu.be/Lhu3MsXZy-Q

Hint : find length
Sort 0, 1, 2 Linked List

Given a linked list of N nodes where nodes can contain values 0s, 1s, and 2s only. The task is to segregate 0s, 1s, and 2s linked list such that all zeros segregate to head side, 2s at the end of the linked list, and 1s in the mid of 0s and 2s.

Question ID : 0606231420

Easy
Linked List

Problem : https://bit.ly/3Ceotvr

Hint : count sort
Intersection of Two Linked Lists

Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.

Question ID : 0606231429

Medium
ReVisit
Linked List

Problem : https://leetcode.com/problems/intersection-of-two-linked-lists/

Solution : https://youtu.be/u4FWXfgS8jw?t=47

Hint : find length of two lists, place two pointers with difference in lengths.
Add 1 to a number represented as linked list

A number N is represented in Linked List such that each digit corresponds to a node in linked list. You need to add 1 to it.

Question ID : 0606231503

Medium
Linked List
ReVisit

Problem : https://bit.ly/3piCTD3

Hint : find lastnode which is not 9
Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

Question ID : 0606231804

Medium
ReVisit
Linked List

Problem : https://leetcode.com/problems/add-two-numbers/

Solution : https://youtu.be/LBVsXSMOIk4

Hint : sum, carry
rotate list

Given the head of a linked list, rotate the list to the right by k places.

Question ID : 0606231842

Medium
Linked List

Problem : https://bit.ly/3JXvemY

Solution : https://youtu.be/9VPm6nEbVPA?t=26

Hint : same as arrays
Flattening a Linked List

Given a Linked List of size N, where every node represents a sub-linked-list and contains two pointers:
(i) a next pointer to the next node,
(ii) a bottom pointer to a linked list where this node is head.
Each of the sub-linked-list is in sorted order.
Flatten the Link List such that all the nodes appear in a single level while maintaining the sorted order.
Note: The flattened list will be printed using the bottom pointer instead of the next pointer

Question ID : 0606231925

Hard
Linked List
ReVisit

Problem : https://bit.ly/3w9TKf8

Solution : https://youtu.be/ysytSSXpAI0

Hint : like merge two sorted arrays
Reverse Nodes in k-Group

Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list.
k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is.
You may not alter the values in the list's nodes, only nodes themselves may be changed.

Question ID : 0606232044

Hard
ReVisit
LinkedList

Problem : https://leetcode.com/problems/reverse-nodes-in-k-group/

Solution : https://youtu.be/Of0HPkk3JgI

Hint : curr, pre, nex
Sort LinkedList

Question ID : 0606232151

Hard
Linked List

Problem : https://bit.ly/3dDuLdO

Hint : merge sort
Segregate even and odd nodes in a Link List

Given a link list of size N, modify the list such that all the even numbers appear before all the odd numbers in the modified list. The order of appearance of numbers within each segregation should be same as that in the original list.
NOTE: Don't create a new linked list, instead rearrange the provided one.

Question ID : 0706231112

Medium
Linked List

Problem : https://bit.ly/3A3aeqe

Hint : dummyEven,dummyOdd,etail,otail, like merge sorted lists.
Majority Element n / 3

Question ID : 0706231309

Medium
ReVisit
Arrays

Problem : https://leetcode.com/problems/majority-element-ii/

Solution : https://youtu.be/vwZj1K0e9U8

Hint : modification of moovers voting algorithm. (n / 2)
Merge Without Extra Space

Given two sorted arrays arr1[] and arr2[] of sizes n and m in non-decreasing order. Merge them in sorted order without using any extra space. Modify arr1 so that it contains the first N elements and modify arr2 so that it contains the last M elements.

Question ID : 0706231341

Medium
Arrays

Problem : https://bit.ly/3zRzmAo

Solution : https://youtu.be/n7uwj04E0I4

Hint : compare last of one array and start of second array
Overlapping Intervals

Given a collection of Intervals, the task is to merge all of the overlapping Intervals.

Question ID : 0706231349

Medium
Arrays

Problem : https://bit.ly/3zRz904

Solution : https://youtu.be/IexN60k62jo

Find Missing And Repeating

Given an unsorted array Arr of size N of positive integers. One number 'A' from set {1, 2,....,N} is missing and one number 'B' occurs twice in array. Find these two numbers.

Question ID : 0706231902

Medium
ReVisit

Problem : https://bit.ly/3zWZoCs

Solution : https://youtu.be/2D0D8HE6uak

Hint : sum of n, sum of squares of n ,
Subsets with XOR value

Given an array arr of N integers and an integer K, find the number of subsets of arr having XOR of elements as K.

Question ID : 0706231929

Medium
Arrays
ReVisit

Problem : https://bit.ly/3jLfElm

Solution : https://youtu.be/eZr-6p0B7ME

Hint : cummulative xor = xr, check map for (xr ^ k)
Count Inversions

Inversion Count: For an array, inversion count indicates how far (or close) the array is from being sorted. If array is already sorted then the inversion count is 0. If an array is sorted in the reverse order then the inversion count is the maximum.
Formally, two elements a[i] and a[j] form an inversion if a[i] > a[j] and i < j.

Question ID : 0706232001

Hard
Arrays
ReVisit

Problem : https://bit.ly/3GJcuYj

Solution : https://youtu.be/AseUmwVNaoY

Hint : like merge sort, cnt += (m - i)
Reverse Pairs

Given an integer array nums, return the number of reverse pairs in the array.
A reverse pair is a pair (i, j) where: i < j and nums[i] > 2 * nums[j].

Question ID : 0706232149

Hard
Arrays

Problem : https://leetcode.com/problems/reverse-pairs/

Solution : https://youtu.be/0e4bZaP3MDI

Hint : modification of countInversions
Maximum Product Subarray

Given an integer array nums, find a subarray that has the largest product, and return the product.

Question ID : 0806230743

Hard
Arrays
ReVisit

Problem : https://bit.ly/3VPdyyq

Solution : https://youtu.be/hnswaLJvr6g

Hint : leftMax, rightMax, zeroPresent?
Binary Search

Given a sorted array of size N and an integer K, find the position(0-based indexing) at which K is present in the array using binary search.

Question ID : 1006231212

Easy
Arrays
Binary

Problem : https://bit.ly/3QtKBpO

Solution : https://youtu.be/MHf6awe89xw

Hint : l <= r, l = m+1, r = m-1
Floor in a Sorted Array

Given a sorted array arr[] of size N without duplicates, and given a value x. Floor of x is defined as the largest element K in arr[] such that K is smaller than or equal to x.

Question ID : 1006231242

Easy
Binary
Arrays

Problem : https://bit.ly/3Cf398N

Solution : https://youtu.be/6zhGS79oQ4k

Hint : vec[m] < k, ans = m
Implement Upper Bound

Given a sorted array arr[] of size N without duplicates, and given a value x. Floor of x is defined as the largest element K in arr[] such that K is larger than or equal to x.

Question ID : 1006231252

Easy
Binary
Arrays

Problem : https://bit.ly/3Cf398N

Solution : https://youtu.be/6zhGS79oQ4k

Hint : ans = n, vec[m] > k -> ans = m
First and last occurrences of x

Question ID : 1006231845

Easy
Binary
Arrays

Problem : https://bit.ly/3QuCFEP

Solution : https://youtu.be/hjR1IYVx9lY

Hint : { lowerBound, upperBound - 1 }
Number of occurrence

Given a sorted array Arr of size N and a number X, you need to find the number of occurrences of X in Arr.

Question ID : 1006231903

Easy
Binary
Arrays

Problem : https://bit.ly/3SVcOqW

Solution : https://youtu.be/hjR1IYVx9lY

Hint : count = ub - lb
Search in Rotated Sorted Array 1

Given a sorted and rotated array A of N distinct elements which is rotated at some point, and given an element key. The task is to find the index of the given element key in the array A. The whole array A is given as the range to search.

Question ID : 1106230810

Medium
Binary
ReVisit
Arrays

Problem : https://bit.ly/3OmIp5d

Solution : https://youtu.be/5qGrJbHhqFs

Hint : check if either part is sorted.
Search in Rotated Sorted Array 2

Question ID : 1106230835

Medium
Binary
Arrays

Problem : https://bit.ly/3MCdLTY

Solution : https://youtu.be/w2G2W8l__pc

Hint : check if either part is sorted
Minimum in Rotated Sorted Array

A sorted(in ascending order) array A[ ] with distinct elements is rotated at some unknown point, the task is to find the minimum element in it.

Question ID : 1106230941

Medium
Arrays
Binary
ReVisit

Problem : https://bit.ly/41My2dR

Solution : https://youtu.be/nhEMDKMB44g

Rotation

Given an ascending sorted rotated array Arr of distinct integers of size N. The array is right rotated K times. Find the value of K.

Question ID : 1106231006

Binary
Medium
Arrays

Problem : https://bit.ly/3pMzTCh

Solution : https://youtu.be/jtSiWTPLwd0

Hint : Index of minimum element
Search in 2D sorted matrix

Given a matrix mat[][] of size N x M, where every row and column is sorted in increasing order, and a number X is given. The task is to find whether element X is present in the matrix or not.

Question ID : 1106231133

Arrays
Binary
Medium

Problem : https://bit.ly/3dAwi3Z

Solution : https://youtu.be/ZYpYur0znng

Hint : start from (0,m-1)
Find a Peak Element II

A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom.
Given a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j].

Question ID : 1106231343

Arrays
Binary
ReVisit
Medium

Problem : https://leetcode.com/problems/find-a-peak-element-ii/

Hint : search max in mid Column,
Median in a row-wise sorted Matrix

Given a row wise sorted matrix of size R*C where R and C are always odd, find the median of the matrix.

Question ID : 1106231759

Medium
Arrays
Binary

Problem : https://bit.ly/3PvwuPk

Solution : https://youtu.be/63fPPOdIr2c

Hint : Binary space
Koko Eating Bananas

Given N piles of bananas, the ith pile has piles[i] bananas and H hours time until guards return (N <= H).
Find the minimum (S) bananas to eat per hour such that Koko can eat all the bananas within H hours.
Each hour, Koko chooses some pile of bananas and eats S bananas from that pile. If the pile has less than S bananas, then she consumes all of them, and wont eat any more bananas during that hour.

Question ID : 1106231858

Medium
Binary

Problem : https://bit.ly/3LSY491

Capacity To Ship Packages Within D Days

Given an array arr[] of N weights. Find the least weight capacity of a boat to ship all weights within D days.
The ith weight has a weight of arr[i]. Each day, we load the boat with weights given by arr[i].We may not load more weight than the maximum weight capacity of the ship.
Note: You have to load weights on the boat in the given order.

Question ID : 1106231928

Medium
Binary

Problem : https://bit.ly/3PBInmS

Median of Two Sorted Arrays

Question ID : 1206230922

Hard
Arrays
ReVisit

Problem : https://bit.ly/3K1HwL4

Solution : https://youtu.be/NTop3VTjmxk

Hint : cut1, cut2, l1 l2, r1 r2
Aggressive Cows

You are given an array consisting of n integers which denote the position of a stall. You are also given an integer k which denotes the number of aggressive cows.
You are given the task of assigning stalls to k cows such that the minimum distance between any two of them is the maximum possible.

Question ID : 1206231030

Medium
Binary
Arrays
ReVisit

Problem : https://bit.ly/3rBuE5Z

Solution : https://youtu.be/wSOfYesTBRk

Hint : sort the given vector
Allocate Books

You have N books, each with Ai number of pages. M students need to be allocated contiguous books, with each student getting at least one book.
Out of all the permutations, the goal is to find the permutation where the student with the most pages allocated to him gets the minimum number of pages, out of all possible permutations.

Question ID : 1206231040

Medium
Binary
Arrays

Problem : https://bit.ly/3QMrMxP

Solution : https://youtu.be/gYmWHvRHu-s

Hint : low = 0, high = sum of all pages
Outermost Parentheses

Given a valid parentheses string s, consider its primitive decomposition: s = P1 + P2 + ... + Pk, where Pi are primitive valid parentheses strings.
Return s after removing the outermost parentheses of every primitive string in the primitive decomposition of s

Question ID : 1206231206

Easy
Strings
Stack

Problem : https://bit.ly/3rzwRix

Hint : when the stack is empty, add substr
Reverse Words

Given a String S, reverse the string without reversing its individual words. Words are separated by dots.

Question ID : 1206231223

Easy
Strings

Problem : https://bit.ly/3SXyWB4

Largest odd number in string

Question ID : 1206231227

Easy
Strings

Problem : https://bit.ly/3UII5yp

Hint : search for odd integer in string from last
Longest Common Prefix in an Array

Given an array of N strings, find the longest common prefix among all strings present in the array.

Question ID : 1206231729

Easy
Strings
ReVisit

Problem : https://bit.ly/3QKCyVu

Hint : sort the strings, check first and last string.
Isomorphic Strings

Given two strings 'str1' and 'str2', check if these two strings are isomorphic to each other.
Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2 while preserving the order.
Note: All occurrences of every character in str1 should map to the same character in str2

Question ID : 1206231740

Easy
Strings

Problem : https://bit.ly/3QwynwI

Hint : map
Check if strings are rotations of each other or not

Question ID : 1206231749

Easy
Strings

Problem : https://bit.ly/3K0HHq5

Hint : substr
K-th missing element

Given an increasing sequence a[], we need to find the K-th missing contiguous element in the increasing sequence which is not present in the sequence. If no k-th missing element is there output -1.

Question ID : 1206231801

Easy
Arrays

Problem : https://bit.ly/3bUFY9l

Hint : (arr[i+1]-arr[i]) compare with count
Maximum Nesting Depth of the Parentheses

For example , "" , " ( ) ( ) " , and " ( ) ( ( ) ( ) ) " and VPS's (with nesting depths 0 , 1, and 2), and " ) ( " and " ( ( ) " are not VPS's.
Given a VPS represented as string S , return the nesting depth of S.

Question ID : 1206231844

Easy
Strings
Stack

Problem : https://bit.ly/3xYlR1F

Hint : stack
Roman Number to Integer

Given a string in roman no format (s) your task is to convert it to an integer . Various symbols and their values are given below. I 1 ,V 5 , X 10, L 50, C 100, D 500, M 1000

Question ID : 1206231850

Medium
Strings
ReVisit

Problem : https://bit.ly/3AqBlNv

Hint : if (next val is > then current value) then current value is will be subtracted.
Implement Atoi

Your task is to implement the function atoi. The function takes a string(str) as argument and converts it to an integer and returns it.

Question ID : 1206231856

Easy
Strings

Problem : https://bit.ly/3QUHBmf

Count Good Numbers

Given two positive integers L, R and a digit D, find out all the good numbers in the range [L, R], which do not contain the digit D.
A number is a good number if it's every digit is larger than the sum of digits which are on the right side of that digit.
9620 is good as (2 > 0, 6 > 2+0, 9 > 6+2+0)

Question ID : 1206231939

Easy
Recursion

Problem : https://bit.ly/3w6SucH

Sub Strings, No 1 's

Given an integer, K. Generate all binary strings of size k without consecutive 1’s.

Question ID : 1206231954

Easy
Recursion

Problem : https://bit.ly/3QJ0vwc

Hint : pick, not pick
Generate Parentheses

Question ID : 1206232002

Medium
Recursion

Problem : https://bit.ly/3K5keUw

Power Set

Given a string S, Find all the possible subsequences of the String in lexicographically-sorted order.

Question ID : 1206232009

Easy
Recursion

Problem : https://bit.ly/3STXz1t

Solution : https://youtu.be/b7AYbpM5YrE

Subset Sums

Given a list arr of N integers, print sums of all subsets in it.

Question ID : 1206232030

Easy
Recursion

Problem : https://bit.ly/3C9GQRS

Combination Sum

Given an array of integers and a sum B, find all unique combinations in the array where the sum is equal to B. The same number may be chosen from the array any number of times to make B.

Question ID : 1306230925

Medium
Recursion

Problem : https://bit.ly/3C9bJ91

Solution : https://youtu.be/OyZFFqQtu98

Hint : if vec[i] < target don't move index, remove duplicates, sort
Combination Sum II

Question ID : 1306230946

Revisit
Medium
Recursion

Problem : https://bit.ly/3VgczZ2

Solution : https://youtu.be/G1fRTGRxXU8

Hint : sorting
Subset II

You are given an integer array nums that may contain duplicates. Your task is to return all possible subsets. Return only unique subsets and they can be in any order.

Question ID : 1306231034

Medium
Recursion

Problem : https://bit.ly/3MlAvWF

Solution : https://youtu.be/RIn3gOkbhQE

Hint : index to n, move to i + 1
Combination Sum III

Find all valid combinations of K numbers that sum upto to N such that the following conditions are true:
Only number 1 through 9 are used.
Each number is used atmost once.
Return the list of all possible valid combinations.
Note: The list must not contain the same combination twice, and the combinations returned in any order.

Question ID : 1306231102

Medium
Recursion

Problem : https://bit.ly/3CMZFul

Possible Words From Phone Digits

Given a keypad as shown in the diagram, and an N digit number which is represented by array a[ ], the task is to list all words which are possible by pressing these numbers.

Question ID : 1306231237

Medium
Recursion

Problem : https://bit.ly/3K1INBO

Sort Characters By Frequency

Given a string s, sort it in decreasing order based on the frequency of the characters.
Return the sorted string.

Question ID : 1306231706

Medium
ReVisit
Strings

Problem : https://leetcode.com/problems/sort-characters-by-frequency/

Hint : create a hash map using vector<pair<int, char >>
Longest Palindrome in a String

In case of conflict, return the substring which occurs first ( with the least starting index).

Question ID : 1406230842

Medium
ReVisit
Strings

Problem : https://bit.ly/3CeQ27D

Solution : https://youtu.be/XYQecbcd6_c

Hint : get a plaindrome by str[i] in middle, str[i]+str[i+1] in middle
Count number of substrings

Given a string of lowercase alphabets, count all possible substrings (not necessarily distinct) that have exactly k distinct characters.

Question ID : 1406231054

Medium
Strings
ReVisit

Problem : https://bit.ly/3CfQfYi

Hint : uniq(atmost k) - uniq(atmost k-1) == uniq(exact k)
Sum of Beauty of subStrings

Question ID : 1406231136

Medium
Strings

Problem : https://leetcode.com/problems/sum-of-beauty-of-all-substrings/

Solution : https://youtu.be/5XjJs5SBN8g

Hint : vector<int>(26,0) = use it as freq map
Word Search

Given a 2D board of letters and a word. Check if the word exists in the board. The word can be constructed from letters of adjacent cells only. ie - horizontal or vertical neighbors.
The same letter cell can not be used more than once.

Question ID : 1406231714

Hard
Recursion

Problem : https://practice.geeksforgeeks.org/problems/word-search/1

Hint : search for str[index] and make it -1 and search around for str[index+1]
Rat in a Maze Problem - I

Consider a rat placed at (0, 0) in a square matrix of order N * N. It has to reach the destination at (N - 1, N - 1). Find all possible paths that the rat can take to reach from source to destination. The directions in which the rat can move are 'U', 'D', 'L', 'R'. Value 0 at a cell in the matrix represents that it is blocked and rat cannot move to it while value 1 at a cell in the matrix represents that rat can be travel through it.

Question ID : 1406231733

Recursion
Grid

Problem : https://practice.geeksforgeeks.org/problems/rat-in-a-maze-problem/1

Solution : https://youtu.be/bLGZhJlt4y0

Sudoko Solver

Given an incomplete Sudoku configuration in terms of a 9 x 9 2-D square matrix ( grid[][] ), the task to find a solved Sudoku.

Question ID : 1406231744

Medium
Recursion
Grid

Problem : https://practice.geeksforgeeks.org/problems/solve-the-sudoku-1587115621/1

Solution : https://youtu.be/FWAIf_EVUKE

N Queen

The n-queens puzzle is the problem of placing n queens on a (n×n) chessboard such that no two queens can attack each other.
Given an integer n, find all distinct solutions to the n-queens puzzle.

Question ID : 1406231918

Recursion
Grid
ReVisit
Medium

Problem : https://practice.geeksforgeeks.org/problems/n-queen-problem0315/1

Solution : https://youtu.be/i05Ju7AftcM

Hint : keep a queen in one col at some position, go for next col
Insert at Bottom of Stack

Given a value N, a stack st, insert N in the bottom of stack.

Question ID : 1506231033

Medium
Recursion
Stack

Solution : https://www.geeksforgeeks.org/program-to-insert-an-element-at-the-bottom-of-a-stack/

Hint : pop, recursive call
Reverse Stack

Question ID : 1506231042

Medium
Recursion
Stack

Problem : https://bit.ly/3podAiY

Solution : https://youtu.be/SW14tOda_kI

Hint : pop, recursive call, insert at bottom
Sort Stack

Given a stack, the task is to sort it such that the top of the stack has the greatest element.

Question ID : 1506231110

Medium
Stack
ReVisit
Recursion

Problem : https://practice.geeksforgeeks.org/problems/sort-a-stack/1

Solution : https://youtu.be/SjDq1xYxC44

Hint : pop, recursive call, insert sort
Assign Cookies

Assume you are an awesome parent of N children and want to give your children some cookies out of given M cookies. But, you should give each child atmost one cookie.

Each child i has a greed factor greed [ i ], which is the minimum size of cookie that the child will be content with; and each cookie j has a size sz [ j ]. If sz [ j ] >= greed [ i ], we can assign the cookie j to the child ith, and the child i will be content.

Your goal is to maximize the number of your content children and return the maximum number.

Question ID : 1506231616

Easy
Greedy

Problem : https://bit.ly/3Wl3PBd

Hint : sort the given arrays, start from more greedy one
Minimum number of Coins

Given an infinite supply of each denomination of Indian currency { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 } and a target value N.
Find the minimum number of coins and/or notes needed to make the change for Rs N. You must return the list containing the value of coins required.

Question ID : 1506231622

Easy
Greedy

Problem : https://bit.ly/3Ka7xYU

Solution : https://youtu.be/mVg9CfJvayM

Hint : first check with 2000, ..
Lemonade Change

You are an owner of lemonade island, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills).

Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer so that the net transaction is that the customer pays $5.

NOTE: At first, you do not have any bill to provide changes with. You can provide changes from the bills that you got from the previous customers.

Given an integer array bills of size N where bills [ i ] is the bill the ith customer pays, return true if you can provide every customer with the correct change, or false otherwise.

Question ID : 1506231709

Medium
Greedy

Problem : https://bit.ly/3DoFGRx

Hint : cnt_5, cnt_10
Parenthesis Checker

Given an expression string x. Examine whether the pairs and the orders of {,},(,),[,] are correct in exp.

Question ID : 1506231716

Easy
Strings
Stack

Problem : https://bit.ly/3K6ulZA

Hint : stack top == str[i] for closed,
Fractional Knapsack

Given weights and values of N items, we need to put these items in a knapsack of capacity W to get the maximum total value in the knapsack.
Note: Unlike 0/1 knapsack, you are allowed to break the item.

Question ID : 1506231738

Medium
Greedy
ReVisit

Problem : https://bit.ly/3PsqOFL

Solution : https://youtu.be/F_DDzYnxO14

Hint : sort based on (val/gram)
N meetings in one room

There is one meeting room in a firm. There are N meetings in the form of (start[i], end[i]) where start[i] is start time of meeting i and end[i] is finish time of meeting i.

What is the maximum number of meetings that can be accommodated in the meeting room when only one meeting can be held in the meeting room at a particular time?

Question ID : 1506231841

Medium
Greedy

Problem : https://bit.ly/3A6Ob1Y

Solution : https://youtu.be/II6ziNnub1Q

Hint : sort based on end timings
Minimum Platforms

Given arrival and departure times of all trains that reach a railway station. Find the minimum number of platforms required for the railway station so that no train is kept waiting.

Question ID : 1506231934

Medium
Greedy
ReVisit

Problem : https://bit.ly/3bXX5Hm

Solution : https://youtu.be/dxVcMDI7vyI

Hint : sort both start-end arrays, two pointer(like merge sorted arrays)
Job Sequencing Problem

Given a set of N jobs where each jobi has a deadline and profit associated with it.
Each job takes 1 unit of time to complete and only one job can be scheduled at a time. We earn the profit associated with job if and only if the job is completed by its deadline.
Find the number of jobs done and the maximum profit.

Question ID : 1506232023

Medium
Greedy
ReVisit

Problem : https://bit.ly/3Pttpzj

Solution : https://youtu.be/LjPx4wQaRIs

Hint : sort based on profit, create vec of maxDeadline
PreOrder Traversal

Given a root of binary tree, find its preorder traversal.

Question ID : 1606231130

Easy
Trees

Problem : https://bit.ly/3Cb4VIh

Solution : https://youtu.be/RlUu72JrOCQ

Hint : root, left, right
PostOrder Traversal

Given a root of binary tree, find its postorder traversal.

Question ID : 1606231142

Easy
Trees

Problem : https://bit.ly/3SZauQ4

Solution : https://youtu.be/COQOU6klsBg

Hint : left, right, root
InOrder Traversal

Given a root of binary tree, find its inorder traversal.

Question ID : 1606231150

Easy
Trees

Problem : https://bit.ly/3QzNDbU

Solution : https://youtu.be/Z_NEgBgbRVI

Hint : left, root, right
Level Order Traversal

Given a root of binary tree, find its level order traversal.

Question ID : 1606231232

Easy
Trees

Problem : https://bit.ly/3K6t9VR

Solution : https://youtu.be/EoAsWbO7sqg

Hint : queue.front .pop -> push left,right
PreOrder Traversal Iterative

Given a root of binary tree, find its preorder traversal.

Question ID : 1606231857

Easy
Stack
Trees

Problem : https://bit.ly/3Cb4VIh

Solution : https://youtu.be/Bfqd8BsPVuw

Hint : st -> pop -> push right, left
InOrder Traversal Iterative

Given a root of binary tree, find its inorder traversal.

Question ID : 1606231955

Easy
ReVisit
Trees
Stack

Problem : https://bit.ly/3QzNDbU

Solution : https://youtu.be/lxTGsVXjwvM

Hint : while (true) , push end left
Postorder Traversal Iterative

Given a root of binary tree, find the Postorder Traversal of it.

Question ID : 1706230831

Medium
Trees
ReVisit

Problem : https://bit.ly/3Cb5Wjz

Solution : https://youtu.be/2YBhNLodD8Q

Hint : stack [ pop, left, right ], reverse ans
Pre, In, Post in One Traversal

Question ID : 1706230937

Medium
Trees
ReVisit

Solution : https://youtu.be/ySp2epYvgTE

Hint : num1 preOrder, num2 inOrder, num3 postOrder
Height of Binary Tree

Given root of binary tree, find its height.

Question ID : 1706231048

Easy
Trees

Problem : https://bit.ly/3CitiDM

Solution : https://youtu.be/eD3tmO66aBA

Hint : return 1 + max(l,r)
Check for Balanced Tree

Given a binary tree, find if it is height balanced or not.
A tree is height balanced if difference between heights of left and right subtrees is not more than one for all nodes of tree.

Question ID : 1706231054

Easy
Trees

Problem : https://bit.ly/3K9YbfB

Solution : https://youtu.be/Yt50Jfbd8Po

Hint : if (l - r > 1) return false , else check branches
Diameter of Tree

The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes.

Question ID : 1706231108

Easy
Trees

Problem : https://bit.ly/3wcfG9l

Solution : https://youtu.be/Rezetez59Nk

Hint : ans = max(ans, l+r+1)
Maximum path sum from any node

Given a binary tree, the task is to find the maximum path sum. The path may start and end at any node in the tree.

Question ID : 1706231150

Medium
Trees

Problem : https://bit.ly/3QAFjbW

Solution : https://youtu.be/WszrfSwMz58

Hint : l = max(0,leftSum) r = max(0,rightSum) ans = max(ans, l+r+node)
Check Identical Trees

Given two binary trees, the task is to find if both of them are identical or not.

Question ID : 1706231242

Easy
Trees

Problem : https://bit.ly/3c2K52Z

Solution : https://youtu.be/BhuvF_-PWS0

Hint : r1 r2, r1->right && r2->right, r1->left && r1->left
Zig Zag Traversal

Given root of Binary Tree. Find the Zig-Zag Level Order Traversal of the Binary Tree.

Question ID : 1706231709

Easy
Trees

Problem : https://bit.ly/3K4mwn5

Solution : https://youtu.be/3OXWEdlIGl4

Hint : bool for l->r
Boundary Traversal of binary tree

Given a Binary Tree, find its Boundary Traversal. The traversal should be in the following order: leftBoundary, leafNodes, rightBoundary

Question ID : 1706231736

Medium
Trees

Problem : https://bit.ly/3AsfgOK

Solution : https://youtu.be/0ca1nvR0be4

Hint : add root if its not leaf, add left, add leaves, add right
Vertical Order Traversal

Given a Binary Tree, find the vertical traversal of it starting from the leftmost level to the rightmost level.
If there are multiple nodes passing through a vertical line, then they should be printed as they appear in level order traversal of the tree.

Question ID : 1706231849

Medium
Trees

Problem : https://bit.ly/3pqu1er

Solution : https://youtu.be/q_a6lpbKJdw

Hint : map
Top View Of Tree

Given below is a binary tree. The task is to print the top view of binary tree. Top view of a binary tree is the set of nodes visible when the tree is viewed from the top.

Question ID : 1706231903

Medium
Trees

Problem : https://bit.ly/3PsvE5T

Solution : https://youtu.be/Et9OCDNvJ78

Hint : vertical order traversal
Bottom View of Tree

Given a binary tree, print the bottom view from left to right. A node is included in bottom view if it can be seen when we look at the tree from bottom.

Question ID : 1706231910

Medium
Trees

Problem : https://bit.ly/3Asftl0

Solution : https://youtu.be/0FtVY6I4pB8

Hint : vertical order traversal
Left View of Tree

Given a Binary Tree, return Left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from Left side.

Question ID : 1706231916

Easy
Trees

Problem : https://bit.ly/3PCqyE9

Solution : https://youtu.be/KV4mRzTjlAk

Hint : level order traversal
Right View of Tree

Given a Binary Tree, find Right view of it. Right view of a Binary Tree is set of nodes visible when tree is viewed from right side.

Question ID : 1706231924

Easy
Trees

Problem : https://practice.geeksforgeeks.org/problems/right-view-of-binary-tree/1

Solution : https://youtu.be/KV4mRzTjlAk

Hint : level order traversal
Symmetric Tree

Given a Binary Tree. Check whether it is Symmetric or not, i.e. whether the binary tree is a Mirror image of itself or not.

Question ID : 1706231939

Easy
Trees

Problem : https://bit.ly/3PCqBzP

Solution : https://youtu.be/nKggNAiEpBE

Hint : r1 r2, r1->left r2->right, r1->right r2->left
Root to Leaf Paths

Given a Binary Tree of size N, you need to find all the possible paths from root node to all the leaf node's of the binary tree.

Question ID : 1806230804

Medium
Trees

Problem : https://bit.ly/3QA600D

Solution : https://youtu.be/fmflMqVOC7k

Path to Given Node

Given a Binary Tree A containing N nodes. You need to find the path from Root to a given node B.

Question ID : 1806230817

Medium
Trees

Problem : https://www.interviewbit.com/problems/path-to-given-node/

Solution : https://youtu.be/fmflMqVOC7k

Hint : root to root distance is 0
Lowest Common Ancestor in a Binary Tree

Given a Binary Tree with all unique values and two nodes value, n1 and n2. The task is to find the lowest common ancestor of the given two nodes. We may assume that either both n1 and n2 are present in the tree or none of them are present.
LCA: It is the first common ancestor of both the nodes n1 and n2 from bottom of tree.

Question ID : 1806230931

Medium
Trees

Problem : https://bit.ly/3popvgG

Solution : https://youtu.be/_-QHfMDde90

Maximum Width of Tree

Given a Binary Tree, find the maximum width of it. Maximum width is defined as the maximum number of nodes at any level.
The width of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes), where the null nodes between the end-nodes that would be present in a complete binary tree extending down to that level are also counted into the length calculation.

Question ID : 1806230941

Medium
ReVisit
Trees

Problem : https://leetcode.com/problems/maximum-width-of-binary-tree/

Solution : https://youtu.be/ZbybYvcVLks

Hint : levelOrder traversal with considering x-cords
Children Sum Parent

Given a Binary Tree. Check whether all of its nodes have the value equal to the sum of their child nodes.

Question ID : 1806231045

Hard
Trees
ReVisit

Problem : https://www.codingninjas.com/codestudio/problems/childrensumproperty_790723

Solution : https://youtu.be/fnmisPM6cVo

Hint : if (childSum > root->Data change root Data), else change child->data ,
recursive call(left,right), root->data = childSum
Nodes at given distance in binary tree

Given a binary tree, a target node in the binary tree, and an integer value k, find all the nodes that are at distance k from the given target node. No parent pointers are available.

Question ID : 1806231112

Medium
Trees

Problem : https://bit.ly/3QytIu6

Solution : https://youtu.be/i9ORlEy6EsI

Hint : create parent pointers
Burning Tree

Given a binary tree and a node data called target. Find the minimum time required to burn the complete binary tree if the target is set on fire. It is known that in 1 second all nodes connected to a given node get burned. That is its left child, right child, and parent.

Question ID : 1806231142

Medium
Trees

Problem : https://bit.ly/3wcg7k1

Solution : https://youtu.be/2r5wLmQfD6g

Hint : parent pointers, node at max dis = ans
Count Number of Nodes in a Binary Tree

You are given the root of a complete binary tree. Your task is to find the count of nodes.
A complete binary tree is a binary tree whose, all levels except the last one are completely filled, the last level may or may not be completely filled and Nodes in the last level are as left as possible.

Question ID : 1806231644

Medium
Trees

Problem : https://bit.ly/3EoPFXM

Solution : https://youtu.be/u-yWemKGWO0

Hint : LH == RH -> 2**n - 1, 1 + lh + rh
Construct Tree from Inorder & Preorder

Given 2 Arrays of Inorder and preorder traversal. The tree can contain duplicate elements. Construct a tree and print the Postorder traversal.

Question ID : 1806231905

Hard
Trees
Revisit

Problem : https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/

Solution : https://youtu.be/aZNaLrVebKQ

Hint : pre[start] = root, pre[start .. n] left, pre[n+1 .. end] right
Construct Tree from Inorder & Postorder

Given inorder and postorder traversals of a Binary Tree in the arrays in[] and post[] respectively. The task is to construct the binary tree from these traversals.

Question ID : 1806232004

Hard
ReVisit

Problem : https://bit.ly/3wbFiTI

Solution : https://youtu.be/LgLRTaEMRVc

Hint : pre[end] = root, pre[end .. end-n] right, pre[end-n-1 .. start] left
Serialize and Deserialize a Binary Tree

Serialization is to store a tree in an array so that it can be later restored and Deserialization is reading tree back from the array. Now your task is to complete the function serialize which stores the tree into an array A[ ] and deSerialize which deserializes the array to the tree and returns it.

Question ID : 1906230815

Medium
Tress

Problem : https://leetcode.com/problems/serialize-and-deserialize-binary-tree/

Solution : https://youtu.be/-YbXySKJsX8

Hint : deserialize (root , left, right)
Flatten tree to linked list

Given the root of a binary tree, flatten the tree into a "linked list":
The "linked list" should use the same Node class where the right child pointer points to the next node in the list and the left child pointer is always null.
The "linked list" should be in the same order as a pre-order traversal of the binary tree.

Question ID : 1906230956

Medium
Trees
ReVisit
Stack

Problem : https://bit.ly/3PFzwko

Solution : https://youtu.be/sWf7k1x9XR4

Hint : st, [ t = pop, right , left] , t -> right = st.top()
Search a node in BST

Given an array of integers in[] representing inorder traversal of elements of a binary tree. Return true if the given inorder traversal can be of a valid Binary Search Tree.

Question ID : 1906231019

BST
Easy

Problem : https://practice.geeksforgeeks.org/problems/search-a-node-in-bst/1

Solution : https://youtu.be/KcNt6v_56cc

Hint : left < root < right
Find min / max in BST

Given a Binary Search Tree. The task is to find the minimum valued element in this given BST.

Question ID : 1906231031

Easy
BST

Problem : https://practice.geeksforgeeks.org/problems/minimum-element-in-bst/1

Hint : min = leftMost, max = rightMost
Ceil in BST

Given a BST and a number X, find Ceil of X.
Note: Ceil(X) is a number that is either equal to X or is immediately greater than X.

Question ID : 1906231038

Easy
BST

Problem : https://practice.geeksforgeeks.org/problems/implementing-ceil-in-bst/1

Solution : https://youtu.be/KSsk8AhdOZA

Hint : move right
Floor in BST

You are given a BST(Binary Search Tree) with n number of nodes and value x. your task is to find the greatest value node of the BST which is smaller than or equal to x.
Note: when x is smaller than the smallest node of BST then returns -1.

Question ID : 1906231048

Easy
BST

Problem : https://bit.ly/3TSbXXE

Solution : https://youtu.be/xm_W1ub-K-w

Hint : move left
Insert a node in a BST

Given a BST and a key K. If K is not present in the BST, Insert a new Node with a value equal to K into the BST.
Note: If K is already present in the BST, don't modify the BST.

Question ID : 1906231058

Medium
BST

Problem : https://practice.geeksforgeeks.org/problems/insert-a-node-in-a-bst/1

Solution : https://youtu.be/FiFiNvM29ps

Hint : if ( k < root , root->left == NULL insert ) ( k > root , root->right == NULL insert )
Delete a Node in BST

Given a Binary Search Tree and a node value X. Delete the node with the given value X from the BST. If no node with value x exists, then do not make any change.

Question ID : 1906231350

BST
Hard
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/delete-a-node-from-bst/1

Solution : https://youtu.be/kouxiP_H5WE

Hint : find del_prevNode, all del left < all del right , connect del left to atmost del right
k-th smallest element in BST

Given a BST and an integer K. Find the Kth Smallest element in the BST using O(1) extra space.

Question ID : 1906231751

Easy
BST

Problem : https://practice.geeksforgeeks.org/problems/find-k-th-smallest-element-in-bst/1

Solution : https://youtu.be/f-sj7I5oXEI

Hint : InOrder traversal of BST = sorted Array
Check for BST

Given the root of a binary tree. Check whether it is a BST or not.

Question ID : 1906231806

Easy
Trees

Problem : https://bit.ly/3poHDqN

Solution : https://youtu.be/f-sj7I5oXEI

Hint : root < leftMax, root > rightMin
LCA in BST

Given a Binary Search Tree (with all values unique) and two node values. Find the Lowest Common Ancestors of the two nodes in the BST.

Question ID : 1906231832

Easy
BST

Problem : https://practice.geeksforgeeks.org/problems/lowest-common-ancestor-in-a-bst/1

Solution : https://youtu.be/cX_kPV_foZc

Hint : root > n1, root < n2 root is LCA
Construct BST from PreOrder

Given an array of integers preorder, which represents the preorder traversal of a BST (i.e., binary search tree), construct the tree and return its root.

Question ID : 1906231907

Medium
BST

Problem : https://practice.geeksforgeeks.org/problems/preorder-to-postorder4423/1

Solution : https://youtu.be/UmJT3j26t1I

Hint : root = pre[start], root->left = pre[less than start], root->right = pre[greater than start]
Predecessor and Successor

There is BST given with the root node with the key part as an integer only. You need to find the in-order successor and predecessor of a given key. If either predecessor or successor is not found, then set it to NULL.

Note:- In an inorder traversal the number just smaller than the target is the predecessor and the number just greater than the target is the successor.

Question ID : 2006231147

Medium
BST

Problem : https://practice.geeksforgeeks.org/problems/predecessor-and-successor/1

Solution : https://youtu.be/SXKAD2svfmI

Hint : floor, ceil
Merge two BST 's

Given two BSTs, return elements of both BSTs in sorted form.

Question ID : 2006231217

Medium
BST

Problem : https://practice.geeksforgeeks.org/problems/merge-two-bst-s/1

Hint : ans1 = inorder bst1, ans2 = inorder bst2, merge the sorted arrays
Binary Search Tree Iterator

Question ID : 2006231356

Medium
BST
ReVisit

Problem : https://leetcode.com/problems/binary-search-tree-iterator/

Solution : https://youtu.be/D2jMcmxU4bs

Hint : stack, next =>(stack.top, pop , add all left nodes of top->right )
A pair with given target in BST

Given a Binary Search Tree and a target sum. Check whether there's a pair of Nodes in the BST with value summing up to the target sum.

Question ID : 2006231821

Medium
BST

Problem : https://practice.geeksforgeeks.org/problems/find-a-pair-with-given-target-in-bst/1

Solution : https://youtu.be/ssL3sHwPeb4

Hint :[ inOrder + two sum ] or [ using BST iterator sum ]
Fixing Two nodes of a BST

You are given the root of a binary search tree(BST), where exactly two nodes were swapped by mistake. Fix (or correct) the BST by swapping them back. Do not change the structure of the tree.

Question ID : 2106230815

Medium
ReVisit
BST

Problem : https://bit.ly/3PBJwea

Solution : https://youtu.be/ZWGW7FminDM

Hint : first, middle, last, [root > prev !=> first,last]
Largest BST

Given a binary tree. Find the size of its largest subtree that is a Binary Search Tree.
Note: Here Size is equal to the number of nodes in the subtree.

Question ID : 2106230943

Hard
ReVisit
BST

Problem : https://practice.geeksforgeeks.org/problems/largest-bst/1

Solution : https://youtu.be/X0oXMdtUDwo

Hint : leftMax < root < rightMin
Invert Binary Tree

Given the root of a binary tree, invert [mirror] the tree, and return its root.

Question ID : 2106231136

Easy
Trees

Problem : https://leetcode.com/problems/invert-binary-tree/

Solution : https://youtu.be/XcY9aUlLP_s

Hint :
Connect Nodes at Same Level

Given a binary tree, connect the nodes that are at the same level. The structure of the tree Node contains an addition nextRight pointer for this purpose.

Question ID : 2106231146

Easy
Trees

Problem : https://practice.geeksforgeeks.org/problems/95423710beef46bd66f8dbb48c510b2c320dab05/1

Solution : https://youtu.be/zc9rCww9ZXs

Hint : level order traversal
Maximum Depth of N-ary Tree

Given a n-ary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

Question ID : 2106231157

Medium
Trees

Problem : https://leetcode.com/problems/maximum-depth-of-n-ary-tree/

Solution : https://youtu.be/Wg243C9gjrw

Hint : do traversal, no children => compare maxi
Cousins in Binary Tree II

Given the root of a binary tree, replace the value of each node in the tree with the sum of all its cousins' values.
Two nodes of a binary tree are cousins if they have the same depth with different parents.
Return the root of the modified tree.

Question ID : 2106231405

Medium
ReVisit
Trees

Problem : https://leetcode.com/problems/cousins-in-binary-tree-ii/

Solution : https://youtu.be/TF8jF0PxavM

Hint : level order traversal + total level sum + vector[node*, childSum]
Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

Question ID : 2106231843

Easy
Trees

Problem : https://leetcode.com/problems/minimum-depth-of-binary-tree/

Hint : NULL return INT_MAX, root->left == root->right == NULL = return 1
Path Sum

Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum.

Question ID : 2106231854

Easy
Trees

Problem : https://leetcode.com/problems/path-sum/

Hint : NULL return false, stop at leaf Node
Path Sum II

Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum. Each path should be returned as a list of the node values, not node references.

Question ID : 2106231927

Medium
Trees

Problem : https://leetcode.com/problems/path-sum-ii/

Hint : backtracking + pathSum I
Increasing Triplet Subsequence

Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that
i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return false.

Question ID : 2206231007

Easy
Arrays
ReVisit

Problem : https://leetcode.com/problems/increasing-triplet-subsequence/

Hint : min1, min2 , [ like find second minimum ]
Unique Binary Search Trees

Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n.

Question ID : 2206231039

Medium
BST
ReVisit
DP

Problem : https://leetcode.com/problems/unique-binary-search-trees/

Hint : nTrees(i-1, dp) * nTrees(n-i, dp)
Convert Sorted Array to Binary Search Tree

Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.

Question ID : 2206231056

Medium
BST

Problem : https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/

Hint : (l,r) => if (l > r) return NULL => [ root=(m), left = (l,m-1), right = (m+1, r)]
Unique Binary Search Trees II

Given an integer n, return all the structurally unique BST's (binary search trees), which has exactly n nodes of unique values from 1 to n

Question ID : 2206231427

Medium
ReVisit
BST

Problem : https://leetcode.com/problems/unique-binary-search-trees-ii/

Hint : left,right + [ left * right all combinations using for(for(loop)) ]
Sum Root to Leaf Numbers

You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123.

Question ID : 2206231431

Medium
Trees

Problem : https://leetcode.com/problems/sum-root-to-leaf-numbers/

Hint : path = path*10 + root, stop at leaf nodes, dont consider NULL nodes
Sum of Left Leaves

Given the root of a binary tree, return the sum of all left leaves. A leaf is a node with no children. A left leaf is a leaf that is the left child of another node.

Question ID : 2206231454

Medium
Trees

Problem : https://leetcode.com/problems/sum-of-left-leaves/

Hint : traversal( ans, root, bool fromLeft )
N-ary Tree Level Order Traversal

Given an n-ary tree, return the level order traversal of its nodes' values.

Question ID : 2206231504

Easy
Trees

Problem : https://leetcode.com/problems/n-ary-tree-level-order-traversal/

Hint : for(auto it: f->children) push
Binary Tree Paths

Given the root of a binary tree, return all root-to-leaf paths in any order.

Question ID : 2206231527

Easy
Trees

Problem : https://leetcode.com/problems/binary-tree-paths/

Hint : do any traversal recursive
Find Bottom Left Tree Value

Given the root of a binary tree, return the leftmost value in the last row of the tree.

Question ID : 2206231546

Easy
Trees

Problem : https://leetcode.com/problems/find-bottom-left-tree-value/

Hint : level order traversal
Find Largest Value in Each Tree Row

Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed).

Question ID : 2206231750

Easy
Trees

Problem : https://leetcode.com/problems/find-largest-value-in-each-tree-row/

Hint : level order traversal
Construct String from Binary Tree

Given the root of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.
Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree.

Question ID : 2206231858

Easy
Trees

Problem : https://leetcode.com/problems/construct-string-from-binary-tree/

Hint : root + "(" + l + ")" + "(" + r + ")" [add r if it is non empty]
Convert BST to Greater Tree

Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.

Question ID : 2206231919

Easy
Trees

Problem : https://leetcode.com/problems/convert-bst-to-greater-tree/

Hint : right, [prevSum += root, root = prevSum], left
Binary Tree Tilt

Given the root of a binary tree, return the sum of every tree node's tilt.
The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtree node values.

Question ID : 2306231142

Medium
Trees

Problem : https://leetcode.com/problems/binary-tree-tilt

Hint : traversal( left right ), t = root , root = abs(l-r), ans += root, return (l + r + t)
Find Mode in Binary Search Tree

Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it.
If the tree has more than one mode, return them in any order.

Question ID : 2306231200

Medium
BST

Problem : https://leetcode.com/problems/find-mode-in-binary-search-tree

Hint : inOrderTraversal, find mode in arr
N-ary Tree Preorder Traversal

Given the root of an n-ary tree, return the preorder traversal of its nodes' values.

Question ID : 2306231215

Medium
Trees

Problem : https://leetcode.com/problems/n-ary-tree-preorder-traversal/

N-ary Tree Postorder Traversal

Given the root of an n-ary tree, return the postorder traversal of its nodes' values.

Question ID : 2306231220

Medium
Trees

Problem : https://leetcode.com/problems/n-ary-tree-postorder-traversal/

Average of Levels in Binary Tree

Given the root of a binary tree, return the average value of the nodes on each level in the form of an array.

Question ID : 2306231359

Trees
Easy

Problem : https://leetcode.com/problems/average-of-levels-in-binary-tree/

Hint : level order traversal
Maximum Binary Tree

You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm:
Create a root node whose value is the maximum value in nums.

Question ID : 2306231500

Medium
Trees

Problem : https://leetcode.com/problems/maximum-binary-tree/

Hint : root = max, (left = [l,maxInd-1]), (right = [maxInd+1,r])
Minimum Absolute Difference in BST

Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree.

Question ID : 2306231513

Easy
BST

Problem : https://leetcode.com/problems/minimum-absolute-difference-in-bst/

Hint : inOrder, min(vec[i]-vec[i-1])
Second Minimum Node In a Binary Tree

Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this node's value is the smaller value among its two sub-nodes. More formally, the property root.val = min(root.left.val, root.right.val) always holds. Given such a binary tree, you need to output the second minimum value in the set made of all the nodes' value in the whole tree.
If no such second minimum value exists, output -1 instead.

Question ID : 2306231703

Easy
Trees

Problem : https://leetcode.com/problems/second-minimum-node-in-a-binary-tree/

Hint : min1 = INT_MAX, min2 = -1
Binary Tree Pruning

Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed.

Question ID : 2306231746

Medium
Trees

Problem : https://leetcode.com/problems/binary-tree-pruning/

Hint : l == false = null, r == false = null, [l or r true ]return true
Leaf-Similar Trees

Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence.

Question ID : 2306231808

Medium
Trees

Problem : https://leetcode.com/problems/leaf-similar-trees/

Hint : addLeaf to vector, compare
Subtree of Another Tree

Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.

Question ID : 2306231944

Hard
Trees
ReVisit

Problem : https://leetcode.com/problems/subtree-of-another-tree/

Hint : [root == subRoot -> checkIdentical]
[root != subRoot] check [root->left,subRoot] or
[root->right, subTree]
Longest Univalue Path

Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not pass through the root.
The length of the path between two nodes is represented by the number of edges between them.

Question ID : 2306232157

Hard
ReVisit
Trees

Problem : https://leetcode.com/problems/longest-univalue-path/

Hint : maxC = max(maxC,1+l+r), return 1 + max(ll,rr)
Increasing Order Search Tree

Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child.

Question ID : 2406230816

Medium
ReVisit
BST

Problem : https://leetcode.com/problems/increasing-order-search-tree

Hint : [like flatten tree], dummyRoot = prev,[ inorder travel ] => prev->right = root,prev = root
All Possible Full Binary Trees

Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0.
Each element of the answer is the root node of one possible tree. You may return the final list of trees in any order.
A full binary tree is a binary tree where each node has exactly 0 or 2 children.

Question ID : 2406230847

Medium
Trees

Problem :

Solution :

Hint : [every subTree will have odd no of nodes]
(l,r) => if ((i - l)%2 != 0 && (r-i)%2 != 0)[go for subTree mutiple combinations]
Univalued Binary Tree

A binary tree is uni-valued if every node in the tree has the same value.
Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise.

Question ID : 2406231041

Medium
Trees

Problem : https://leetcode.com/problems/univalued-binary-tree/

Hint : root == left == right -> recursive
Cousins in Binary Tree

Given the root of a binary tree with unique values and the values of two different nodes of the tree x and y, return true if the nodes corresponding to the values x and y in the tree are cousins, or false otherwise.
Two nodes of a binary tree are cousins if they have the same depth with different parents.

Question ID : 2406231215

Easy
Trees

Problem : https://leetcode.com/problems/cousins-in-binary-tree/

Hint : levelOrder Traversal
Construct Binary Tree from Pre + Post Traversal

Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the postorder traversal of the same tree, reconstruct and return the binary tree.
If there exist multiple answers, you can return any of them.

Question ID : 2406231252

Hard
ReVisit
Trees

Problem : https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/

Hint :root = preOrder[l],
ii = index of (postOrder[l] - 1) in preOrder
[l + 1, ii-1] [ii,r]
Smallest Subtree with all the Deepest Nodes

Given the root of a binary tree, the depth of each node is the shortest distance to the root
Return the smallest subtree such that it contains all the deepest nodes in the original tree.

Question ID : 2406231526

Medium
Trees

Problem : https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/

Hint : [height of tree], [l == r return (1 + l),root],
[ return (1+max(l,r)),maxRoot(l,r)]
Smallest String Starting From Leaf

You are given the root of a binary tree where each node has a value in the range [0, 25] representing the letters 'a' to 'z'.
Return the lexicographically smallest string that starts at a leaf of this tree and ends at the root.

Question ID : 2406231552

Easy
Trees

Problem : https://leetcode.com/problems/smallest-string-starting-from-leaf/

Hint : vector[string], sort
Add One Row to Tree

Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth.

Question ID : 2406231913

Easy
Trees

Problem : https://leetcode.com/problems/add-one-row-to-tree/

Hint : level order traversal, depth-1
Merge Two Binary Trees

You are given two binary trees root1 and root2.
Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of the new tree.
Return the merged tree.

Question ID : 2406232111

Medium
ReVisit
Trees

Problem :

Hint : t1->va += t2->val,t1->left = merg(t1 left,t2 left) return t1
Trim BST

Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of the elements that will remain in the tree.

Question ID : 2406232141

Medium
Trees

Problem :

Hint : [root < low => trim(right)] [root > high => trim(left)]
[root->left = trim(left)], [root->right = trim(right)]
Maximum Consecutive Ones

Given a binary array 'ARR' of size 'N', your task is to find the longest sequence of continuous 1’s that can be formed by replacing at-most 'K' zeroes by ones. Return the length of this longest sequence of continuous 1’s.

Question ID : 2506230627

Arrays
Medium

Problem : https://www.codingninjas.com/codestudio/problems/maximum-consecutive-ones_892994

Hint : (l, r) move r until we counted k zeros, then move l
Rotate Elements

Given a 2-dimensional matrix of size ‘N’ x ‘M’, rotate the elements of the matrix clockwise.
The output matrix is generated by rotating the elements of the input matrix in a clockwise direction. Note that every element is rotated only once.

Question ID : 2506230632

Medium
ReVisit
Arrays

Problem : https://www.codingninjas.com/codestudio/problems/981260?topList=striver-sde-sheet-problems&utm_source=striver&utm_medium=website&leftPanelTab=0

Hint : spiral traversal, prev
BFS of graph

Given a directed graph. The task is to do Breadth First Traversal of this graph starting from 0.

Question ID : 2506231217

Easy
Graphs

Problem : https://practice.geeksforgeeks.org/problems/bfs-traversal-of-graph/1

Solution : https://youtu.be/-tgVpUgsQ5k

Hint : like level order traversal
DFS of Graph

You are given a connected undirected graph. Perform a Depth First Traversal of the graph.

Question ID : 2506231234

Easy
Graphs

Problem : https://practice.geeksforgeeks.org/problems/depth-first-traversal-for-a-graph/1

Solution : https://youtu.be/Qzf1a--rhp8

Hint : recursive
Number of Provinces

Given an undirected graph with V vertices. We say two vertices u and v belong to a single province if there is a path from u to v or v to u. Your task is to find the number of provinces.

Question ID : 2506231237

Easy
Graphs

Problem : https://practice.geeksforgeeks.org/problems/number-of-provinces/1

Solution : https://youtu.be/ACzkVtewUYA

Hint : no of times dfs operated
Find the number of islands

Given a grid of size n*m (n is the number of rows and m is the number of columns in the grid) consisting of '0's (Water) and '1's(Land). Find the number of islands.

Question ID : 2506231521

Easy
Graphs

Problem : https://bit.ly/3oT9Ndg

Solution : https://youtu.be/muncqlKJrH0

Hint : bfs, move four directions mark zero while moving
Rotten Oranges

Given a grid of dimension nxm where each cell in the grid can have values 0, 1 or 2 which has the following meaning:
0 : Empty cell
1 : Cells have fresh oranges
2 : Cells have rotten oranges
We have to determine what is the minimum time required to rot all oranges.

Question ID : 2506231534

Easy
Graphs

Problem : https://bit.ly/3R4htWb

Solution : https://youtu.be/yf3oUhkvqA0

Hint : bfs {index of orange, time}
Flood fill Algorithm

Given a coordinate (sr, sc) of the flood fill, and a pixel value newColor, "flood fill" the image.

Question ID : 2506231552

Easy
Graphs

Problem : https://practice.geeksforgeeks.org/problems/flood-fill-algorithm1856/1

Solution : https://youtu.be/C-2_uSRli8o

Hint : from sr,sc to only intial[sr][sc] nodes will effect
Distance of nearest 1

Find the distance of the nearest 1 in the grid for each cell.

Question ID : 2506231745

Easy
Graphs

Problem : https://practice.geeksforgeeks.org/problems/distance-of-nearest-cell-having-1-1587115620/1

Solution : https://youtu.be/edXdVwkYHF8

Hint : bfs from 1's
Replace O's with X's

Given a matrix mat of size N x M where every element is either O or X.
Replace all O with X that are surrounded by X.

Question ID : 2606230825

Easy
Graphs

Problem : https://practice.geeksforgeeks.org/problems/replace-os-with-xs0052/1

Solution : https://youtu.be/BtdgAys4yMk

Hint : bfs from boundary 'O'
Number Of Enclaves

Find the number of land cells in grid for which we cannot walk off the boundary of the grid in any number of moves.

Question ID : 2606231029

Easy
Graphs

Problem : https://practice.geeksforgeeks.org/problems/number-of-enclaves/1

Solution : https://youtu.be/rxKcepXQgU4

Hint : bfs from boundary 1's
Number of Distinct Islands

Given a 10 grid. You have to find the number of distinct islands where a group of connected 1s (horizontally or vertically) forms an island. Two islands are considered to be distinct if and only if one island is not equal to another (not rotated or reflected).

Question ID : 2606231716

Graphs
Medium

Problem : https://practice.geeksforgeeks.org/problems/number-of-distinct-islands/1

Solution : https://youtu.be/7zmgQSJghpo

Hint : start bfs from 1's and use it as [0, 0]
Detect cycle in an undirected graph BFS

Given an undirected graph with V vertices and E edges, check whether it contains any cycle or not. Graph is in the form of adjacency list where adj[i] contains all the nodes ith node is having edge with.

Question ID : 2606231753

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/detect-cycle-in-an-undirected-graph/1

Solution : https://youtu.be/BPlrALf1LDU

Hint : bfs (node,parent), already visited [visNode != parentNode return false]
Detect cycle in an undirected graph DFS

Given an undirected graph with V vertices and E edges, check whether it contains any cycle or not. Graph is in the form of adjacency list where adj[i] contains all the nodes ith node is having edge with.

Question ID : 2606231758

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/detect-cycle-in-an-undirected-graph/1

Solution : https://youtu.be/zQ3zgFypzX4

Hint : dfs (node), already visited return true
Bipartite Graph BFS

Given an adjacency list of a graph adj of V no. of vertices having 0 based index. Check whether the graph is bipartite or not.

Question ID : 2606231812

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/bipartite-graph/1

Solution : https://youtu.be/-vu34sct1g8

Hint : bfs(node,color) -> adjNode visited (same color) return false
Bipartite Graph DFS

Given an adjacency list of a graph adj of V no. of vertices having 0 based index. Check whether the graph is bipartite or not.

Question ID : 2606231838

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/bipartite-graph/1

Solution : https://youtu.be/KG5YFfR0j8A

Hint : dfs(node,color) -> adjNode visited (same color) return false
Detect cycle in a directed graph

Given a Directed Graph with V vertices (Numbered from 0 to V-1) and E edges, check whether it contains any cycle or not.

Question ID : 2606231917

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/detect-cycle-in-a-directed-graph/1

Solution : https://youtu.be/9twcmtQj4DU

Hint : vis[i] = 1 [visited]
vis[i] = 2 pathVisited,
[for cycle check pathVisited]
Eventual Safe States

A node is a terminal node if there are no outgoing edges. A node is a safe node if every possible path starting from that node leads to a terminal node. You have to return an array containing all the safe nodes of the graph.

Question ID : 2606232028

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/eventual-safe-states/1

Solution : https://youtu.be/uRbJ1OF9aYM

Hint : nodes, which are not involved in cycle and not connected in cycle
Topological sort DFS

Given a Directed Acyclic Graph (DAG) with V vertices and E edges, Find any Topological Sorting of that Graph. linear ordering i.e if there is a edge btw u -> v , v appears first.

Question ID : 2706231113

Medium
ReVisit
Graphs

Problem : https://practice.geeksforgeeks.org/problems/topological-sort/1

Solution : https://youtu.be/5lZ0iJMrUMk

Hint : first dfs completed , first in topological sort
Topo sort | Khan's Algo

Given a Directed Acyclic Graph (DAG) with V vertices and E edges, Find any Topological Sorting of that Graph. linear ordering i.e if there is a edge btw u -> v , v appears first.

Question ID : 2706231133

Medium
ReVisit
Graphs

Problem : https://practice.geeksforgeeks.org/problems/topological-sort/1

Solution : https://youtu.be/73sneFXuTEg

Hint : degree = no of incoming edges, [bfs start with 0 degree],
[adj of top of q subtract degree if 0 push],
ans = pop elements
Detect cycle in a directed graph

Given a Directed Graph with V vertices (Numbered from 0 to V-1) and E edges, check whether it contains any cycle or not.

Question ID : 2706231151

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/detect-cycle-in-a-directed-graph/1

Solution : https://youtu.be/iTBaI90lpDQ

Hint : cnt[topo sort == v -> no cycle]
Course Schedule

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites tasks, for example to pick task 0 you have to first finish tasks 1,
which is expressed as a pair: [0, 1].
Given the total number of n tasks and a list of prerequisite pairs of size m. Find a ordering of tasks you should pick to finish all tasks.

Question ID : 2706231356

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/course-schedule/1

Solution : https://youtu.be/WAOfKpxYHR8

Hint : create a adj[], perform topoSort Khan's algo
Eventual Safe nodes | topoSort

A node is a terminal node if there are no outgoing edges. A node is a safe node if every possible path starting from that node leads to a terminal node. You have to return an array containing all the safe nodes of the graph.

Question ID : 2706231411

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/eventual-safe-states/1

Solution : https://youtu.be/2gtg3VsDGyc

Hint : reverse edges + topoSort
Alien Dictionary

Given a sorted dictionary of an alien language having N words and k starting alphabets of standard dictionary. Find the order of characters in the alien language.

Question ID : 2706231500

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/alien-dictionary/1

Solution : https://youtu.be/U3N_je7tWAs

Hint : compare adjacent words + topoSort
Shortest path in DAG

Given a Directed Acyclic Graph of N vertices from 0 to N-1 and a 2D Integer array(or vector) edges[ ][ ] of length M, where there is a directed edge from edge[i][0] to edge[i][1] with a distance of edge[i][2] for all i, 0<=i.
Find the shortest path from src(0) vertex to all the vertices and if it is impossible to reach any vertex, then return -1 for that vertex.

Question ID : 2706231621

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/shortest-path-in-undirected-graph/1?

Solution : https://youtu.be/ZUFQfFaU-8U

Hint : DFS topoSortStack -> distanceVector
Shortest path in Undirected Graph having unit distance

You are given an Undirected Graph having unit weight, Find the shortest path from src to all the vertex and if it is unreachable to reach any vertex, then return -1 for that vertex.

Question ID : 2706231712

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/shortest-path-in-undirected-graph-having-unit-distance/1

Solution : https://youtu.be/C4gxoTaI71U

Hint : vis[v], q({src,0}) bfs
Word Ladder I

Given two distinct words startWord and targetWord, and a list denoting wordList of unique words of equal lengths. Find the length of the shortest transformation sequence from startWord to targetWord.

Question ID : 2806230812

Medium
ReVisit
Graphs

Problem : https://practice.geeksforgeeks.org/problems/word-ladder/1

Solution : https://youtu.be/tRPda0rcf8E

Hint : str[every char check with a to z] -> q.push -> replace original char
Word Ladder II

Given two distinct words startWord and targetWord, and a list denoting wordList of unique words of equal lengths. Find all shortest transformation sequence(s) from startWord to targetWord.

Question ID : 2806231026

Hard
ReVisit
Graphs

Problem : https://practice.geeksforgeeks.org/problems/word-ladder-ii/1

Solution : https://youtu.be/tRPda0rcf8E

Hint : marks words used in level, after completing level then remove from dict
Dijkstra Algorithm

Given a weighted, undirected and connected graph of V vertices and an adjacency list adj where adj[i] is a list of lists containing two integers where the first integer of each list j denotes there is edge between i and j , second integers corresponds to the weight of that edge .
You are given the source vertex S and You to Find the shortest distance of all the vertex's from the source vertex S

Question ID : 2806231115

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/implementing-dijkstra-set-1-adjacency-matrix/1

Solution : https://youtu.be/V6H1qAeB-l4

Hint : pq({dis = 0,node = src}), pop compare adjNode push
Shortest Path in Weighted undirected graph

You are given a weighted undirected graph having n vertices numbered from 1 to n and m edges describing there are edges between a to b with some weight, find the shortest path between the vertex 1 and the vertex n.

Question ID : 2806231428

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/shortest-path-in-weighted-undirected-graph/1

Solution : https://youtu.be/rp1SMw7HSO8

Hint : pq(dist, vector path)
Shortest Distance in a Binary Maze

Given a n * m grid, each element can be 0 or 1. You need to find the shortest distance between a given source cell to a destination cell. The path can only be created out of a cell if its value is 1.

Question ID : 2806231458

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/shortest-path-in-a-binary-maze-1655453161/1

Solution : https://youtu.be/U5Mw4eyUmw4

Hint : bfs / flood fill
Path with Maximum Probability

You are given an undirected weighted graph of n nodes (0-indexed),connecting the nodes a and b with a probability of success of traversing that edge succProb[i].Given two nodes start and end.
find the path with the maximum probability of success to go from start to end and return its success probability.

Question ID : 2806231518

Graphs
Medium

Problem : https://leetcode.com/problems/path-with-maximum-probability/

Solution : https://youtu.be/aPThR7YBCAM

Hint : prob[src] = 1, pq{1,src} (more probabily on top), dijkstra's
Path With Minimum Effort

You are given heights, a 2D array. where heights[row][col] = the height of cell (row, col).
You have to travel from (0, 0) to (rows-1, columns-1).find a route that requires the minimum effort.
A route's effort is the maximum absolute difference in heights between two consecutive cells of the route.

Question ID : 2806231923

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/path-with-minimum-effort/1

Solution : https://youtu.be/0ytpZyiZFhA

Hint : newDist = max(abs(heights[x1][y1] - heights[x2][y2]), d)
Cheapest Flights Within K Stops

There are n cities and m edges connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from the city fromi to city toi with cost pricei.
You are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k stops.

Question ID : 2806232002

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/cheapest-flights-within-k-stops/1

Solution : https://youtu.be/9XybHVqTHcQ

Hint : queue({stops, {node, price}})
Minimum Multiplications to reach End

Given start, end and an array arr of n numbers. At each step, start is multiplied with any number in the array and then mod operation with 100000 is done to get the new start.
Your task is to find the minimum steps in which end can be achieved starting from start. If it is not possible to reach end, then return -1.

Question ID : 2906230747

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/minimum-multiplications-to-reach-end/1

Solution : https://youtu.be/_BvEJ3VIDWw

Hint : cnt[100000], all possible multiplications are in range(1,10^5),
queue
No of Ways to Arrive at Destination

You are given an integer n and a 2D integer array roads where roads[i] = [ui, vi, timei] means that there is a road between intersections ui and vi that takes timei minutes to travel.
You want to know in how many ways you can travel from intersection 0 to intersection n - 1 in the shortest amount of time.
Return the number of ways you can arrive at your destination in the shortest amount of time.

Question ID : 2906230801

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/number-of-ways-to-arrive-at-destination/1

Solution : https://youtu.be/_-0mx0SmYxA

Hint : pq(time,node)
Bellman-Ford Algorithm

Given a weighted, directed and connected graph of V vertices and E edges, Find the shortest distance of all the vertex's from the source vertex S.
Note: If the Graph contains a negative cycle then return an array consisting of only -1.

Question ID : 2906231036

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/distance-from-the-source-bellman-ford-algorithm/1

Solution : https://youtu.be/0vVofAhAYjc

Hint : for(all edges, v-1 times){ (dis[u] + d < dist[v] relax) }
Floyd Warshall

The problem is to find the shortest distances between every pair of vertices in a given edge-weighted directed graph. The graph is represented as an adjacency matrix of size n*n. Matrix[i][j] denotes the weight of the edge from i to j. If Matrix[i][j]=-1, it means there is no edge from i to j.

Question ID : 2906231052

Medium
Graphs
ReVisit

Problem : https://youtu.be/YbY8cVwWAvw

Solution : https://practice.geeksforgeeks.org/problems/implementing-floyd-warshall2042/1

Hint : if (dist[a][i] + dist[i][b] < dist[a][b])
i.e going a to b via i
City With the Smallest Number of Neighbors at a Threshold Distance

There are n cities numbered from 0 to n-1. Given the array edges of a bidirectional and weighted edge, and given the integer distance Threshold.
You need to find out a city with the smallest number of cities that are reachable through some path and whose distance is at most Threshold Distance.

Question ID : 2906231141

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/0

Solution : https://youtu.be/PwMVNSJ5SLI

Hint : floyd warshall algorithm
Minimum travel time

You are given an n x n integer matrix grid where each value grid[i][j] represents height of the cell (i, j).
You can travel from a cell to another 4-directionally adjacent cell if and only the height of the both cells are at most T. You can travel infinite distances in zero time but you must stay within the boundaries of the grid during your travel.
You are currently at cell (0 , 0) and the value of T is 0.and you wish to go to cell (n-1,m-1).
Find the minimum time it will take to reach the cell (n, m) if the value of T increase by 1 every second.

Question ID : 2906231234

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/minimum-travel-time/1

Hint : newD = max(dist[x1][y1], grid[x2][y2],grid[x1][y1])
Prims Algoritm | Min Spanning Tree

Given a weighted, undirected and connected graph of V vertices and E edges. The task is to find the sum of weights of the edges of the Minimum Spanning Tree.

Question ID : 2906231438

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/minimum-spanning-tree/1

Solution : https://youtu.be/mJcZjjKzeqk

Hint : pq(root,node) [vis[node] = 1 after pop]
DisJoint set, Union By rank, Union By size

Question ID : 2906231514

Medium
Graphs
ReVisit

Solution : https://youtu.be/aBxjDBC4M1U

Hint :
Krushal's Algo | minSpanning Tree

Given a weighted, undirected and connected graph of V vertices and E edges. The task is to find the sum of weights of the edges of the Minimum Spanning Tree.

Question ID : 2906231529

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/minimum-spanning-tree/1

Solution : https://youtu.be/DMnDM_sxVig

Hint : disJoint set, sort edges
Connecting the graph

You are given a graph with n vertices and m edges.
You can remove one edge from anywhere and add that edge between any two vertices in one operation.
Find the minimum number of operation that will be required to make the graph connected.

Question ID : 2906231554

Medium
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/connecting-the-graph/1

Solution : https://youtu.be/FYrl7iz9_ZU

Hint : disJoint set, cntExtras, cntComponents
Number Of Islands Stream Operations

Return how many island are there in the matrix after each operation.You need to return an array of size k.

Question ID : 2906231929

Hard
Graphs
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/number-of-islands/1

Solution : https://youtu.be/Rn6B-Q4SNyA

Hint : disJoint set[MakeIsland], convert [i][j] to i*row + j
Maximum Connected group

You are given an n x n binary grid. A grid is said to be binary if every value in grid is either 1 or 0.
You can change at most one cell in grid from 0 to 1.
You need to find the largest group of connected 1's.

Question ID : 2906232011

Graphs
Hard

Problem : https://practice.geeksforgeeks.org/problems/maximum-connected-group/1

Solution : https://youtu.be/lgiz0Oup6gM

Hint : disJoint set, grid[i][j] = 0 check all sides different components
Max Stones Remove

There are n stones at some integer coordinate points on a 2D plane. Each coordinate point may have at most one stone.
You need to remove some stones.
A stone can be removed if it shares either the same row or the same column as another stone that has not been removed.

Question ID : 3006232047

Hard
ReVisit
Graphs

Problem : https://practice.geeksforgeeks.org/problems/maximum-stone-removal-1662179442/1

Solution : https://youtu.be/OwMNX8SPavM

Hint : maxRow, maxCol, ds(row+col+1)
Is edge = bridge

Given a Graph of V vertices and E edges and another edge(c - d), the task is to find if the given edge is a Bridge. i.e., removing the edge disconnects the graph.

Question ID : 3006230954

Medium
Graphs

Problem : https://practice.geeksforgeeks.org/problems/bridge-edge-in-graph/1

Hint : cnt1 Components, remove edge [new adjList] and cnt2 componets
All Bridges in Graph

here are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] represents a connection between servers ai and bi. Any server can reach other servers directly or indirectly through the network.
A critical connection is a connection that, if removed, will make some servers unable to reach some other server.
Return all critical connections in the network in any order.

Question ID : 3006231001

Hard
ReVisit
Graphs

Problem : https://leetcode.com/problems/critical-connections-in-a-network/

Solution : https://youtu.be/qrAub5z8FeA

Hint : tin, low | tin[node] > low[adjNode] = bridge
Count ways to reach the n'th stair

There are n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time. Count the number of ways, the person can reach the top (order does matter).

Question ID : 0407231011

Easy
DP

Problem : https://practice.geeksforgeeks.org/problems/count-ways-to-reach-the-nth-stair-1587115620/1

Solution : https://youtu.be/mLfjzJsN8us

Hint : prev2, prev1 [ curr = prev1 + prev2, prev2 = prev1, prev1 = curr ]
Geek Jump

Geek wants to climb from the 0th stair to the (n-1)th stair. At a time the Geek can climb either one or two steps. A height[N] array is also given. Whenever the geek jumps from stair i to stair j, the energy consumed in the jump is abs(height[i]- height[j]), where abs() means the absolute difference. return the minimum energy that can be used by the Geek to jump from stair 0 to stair N-1.

Question ID : 0407231134

Easy
DP

Problem : https://practice.geeksforgeeks.org/problems/geek-jump/1

Solution : https://youtu.be/EgG3jsGoPvQ

Hint : prev2 = inf, perv1 = 0
Minimal Cost

There are n stones and an array of heights and Geek is standing at stone 1 and can jump to one of the following: Stone i+1, i+2, ... i+k stone and cost will be [hi-hj] is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the Geek reaches Stone N.

Question ID : 0407231203

Medium
ReVisit
DP

Problem : https://practice.geeksforgeeks.org/problems/minimal-cost/1

Solution : https://youtu.be/Kmh3rhyEtB8

Hint : [ i 1 < n] [ j 1 ≤ k] dp[i-j] + abs(height[i] - height[i - j])
Max Sum without Adjacents

Given an array Arr of size N containing positive integers. Find the maximum sum of a subsequence such that no two numbers in the sequence should be adjacent in the array.

Question ID : 0407231238

Easy
DP

Problem : https://practice.geeksforgeeks.org/problems/max-sum-without-adjacents2430/1

Solution : https://youtu.be/GrMBfJNk_NY

Hint : pick, not pick
Geek's Training

Geek is going for n days training program, he can perform any one of these three activities Running, Fighting, and Learning Practice. Each activity has some point on each day. as Geek wants to improve all his skills, he can't do the same activity on two consecutive days, help Geek to maximize his merit points as we were given a 2D array of n*3 points corresponding to each day and activity.

Question ID : 0407231853

Medium
DP
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/geeks-training/1

Solution : https://youtu.be/AE39gJYuRog

Hint : dp[row][col]
Grid Paths 1

Given a A X B matrix with your initial position at the top-left cell, find the number of possible unique paths to reach the bottom-right cell of the matrix from the initial position.

Question ID : 0507231006

Medium
DP

Problem : https://practice.geeksforgeeks.org/problems/number-of-unique-paths5339/1

Solution : https://youtu.be/sdE0A2Oxofw

Hint : perv, curr, up + left
Grid Paths 2

You are given a grid of n * m having 0 and 1 respectively, 0 denotes space, and 1 denotes obstacle. Geek is located at top-left corner (i.e grid[0][0]) and wants to reach the bottom right corner of the grid. A geek can move either down or right at any point of time. return the total number of ways in which Geek can reach bottom right corner.

Question ID : 0507231106

Medium
DP

Problem : https://practice.geeksforgeeks.org/problems/grid-path-2/1

Solution : https://youtu.be/TmhpgXScLyY

Hint : perv, curr, up + left
Min Sum Grid Path

Given a square grid of size N, each cell of which contains integer cost which represents a cost to traverse through that cell, we need to find a path from top left cell to bottom right cell by which the total cost incurred is minimum.

Question ID : 0507231135

Medium
DP

Problem : https://bit.ly/3q5sqfu

Solution : https://youtu.be/_rgTlyky1uQ

Triangle Grid Min / Max Path

Given a triangle array, return the minimum path sum from top to bottom.
For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i or index i + 1 on the next row.

Question ID : 0507231145

Medium
DP
ReVisit

Problem : https://leetcode.com/problems/triangle/

Solution : https://youtu.be/SrP-PiLSYC0

Hint : bottom, curr
Maximum Fall sum in matrix

Given a NxN matrix of positive integers.
Starting from any column in row 0 return the largest sum of any of the paths up to row N-1.

Question ID : 0507231404

Medium
DP
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/path-in-matrix3805/1

Solution : https://youtu.be/N_aJ5qQbYA0

Hint : prev, curr, [ ans = max(prev) ]
Subset Sum Target

Given an array of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given sum.

Question ID : 0607230753

Medium
DP

Problem : https://practice.geeksforgeeks.org/problems/subset-sum-problem-1611555638/1

Solution : https://youtu.be/fWX9xDmIzRI

Hint : pick, notPick
Min sum partition

Given an array arr of size n containing non-negative integers, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum and find the minimum difference

Question ID : 0607230850

Medium
DP
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/minimum-sum-partition3317/1

Solution : https://youtu.be/GS_OqZb2CWc

Hint : pick, not pick, target = 0 to sum
Partition Equal Subset Sum

Question ID : 0607230858

Medium
DP

Problem : https://practice.geeksforgeeks.org/problems/subset-sum-problem2014/1

Solution : https://youtu.be/7win3dcgo3k

Hint : odd sum false, check for target = sum / 2
Count Subsets with Sum K

Given an array arr[] of non-negative integers and an integer sum, the task is to count all subsets of the given array with a sum equal to a given sum.

Question ID : 0607231009

Medium
DP

Problem : https://www.codingninjas.com/studio/problems/number-of-subsets_3952532

Solution : https://youtu.be/ZHyb-A2Mte4

Hint : dp(n,k+1,0)
Partitions with Given Difference

Given an array arr, partition it into two subsets(possibly empty) such that their union is the original array. Let the sum of the element of these two subsets be S1 and S2.
Given a difference d, count the number of partitions in which S1 is greater than or equal to S2 and the difference S1 and S2 is equal to d.

Question ID : 0607231112

Medium
DP

Problem : https://practice.geeksforgeeks.org/problems/partitions-with-given-difference/1

Solution : https://youtu.be/zoilQD1kYSg

Hint : target = (sum + d)/2
0 - 1 Knapsack Problem

given two integer arrays val[0..N-1] and wt[0..N-1] which represent values and weights associated with N items respectively. Also given an integer W which represents knapsack capacity,
find out the maximum value subset of val[] such that sum of the weights of this subset is smaller than or equal to W.

Question ID : 0607231149

Medium
DP
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem0945/1

Solution : https://youtu.be/GqOmJHQZivw

Hint : dp(n,w+1) [base : wt[0] to maxW dp[0][i] = val[0]]
Min Coins infinte supply

You are given an array of ‘N’ distinct integers and an integer ‘X’ representing the target sum. You have to tell the minimum number of elements you have to take to reach the target sum ‘X’.

Question ID : 0607231522

Medium
DP
ReVisit

Problem : https://www.codingninjas.com/studio/problems/minimum-elements_3843091

Solution : https://youtu.be/myPeWb3Y68A

Hint : dp[i][v-coins[i]]
Count Coins infinte supply

You are given an array of ‘N’ distinct integers and an integer ‘X’ representing the target sum. You have to tell the no of ways of elements you have to take to reach the target sum ‘X’.

Question ID : 0607232217

Medium
DP

Problem : https://www.codingninjas.com/studio/problems/ways-to-make-coin-change_630471

Solution : https://youtu.be/HgyouUi11zk

Hint : dp[i][v-coins[i]]
Knapsack Infinite

Given a set of N items, each with a weight and a value, represented by the array w[] and val[] respectively. Also, a knapsack with weight limit W.
The task is to fill the knapsack in such a way that we can get the maximum profit. Return the maximum profit.
Note: Each item can be taken any number of times.

Question ID : 0707230809

Medium
DP

Problem : https://practice.geeksforgeeks.org/problems/knapsack-with-duplicate-items4201/1

Solution : https://youtu.be/OgvOZ6OrJoY

Hint : dp[0][i] = val[0]*(cap / wt[0])
Rod Cutting

Given a rod of length N inches and an array of prices, price[]. price[i] denotes the value of a piece of length i. Determine the maximum value obtain.

Question ID : 0707230827

Medium
DP

Problem : https://practice.geeksforgeeks.org/problems/rod-cutting0840/1

Solution : https://youtu.be/mO8XpGoJwuo

Hint : dp(size n+1 * n+1)
Longest common SubSequence string

Given two sequences, find the length of longest subsequence present in both of them. Both the strings are of uppercase.

Question ID : 0707230846

Medium
DP
Strings

Problem : https://practice.geeksforgeeks.org/problems/longest-common-subsequence-1587115620/1

Solution : https://youtu.be/NPZn9jBrX8U

Hint : dp[i][j] = 0 + max(dp[i-1][j],dp[i][j-1]);
Print all LCS sequences

You are given two strings s and t. Now your task is to print all longest common sub-sequences in lexicographical order.

Question ID : 0707231053

Medium
DP
ReVisit
Strings

Problem : https://practice.geeksforgeeks.org/problems/print-all-lcs-sequences3413/1

Solution : https://youtu.be/-zI4mrF2Pb4

Hint : backTrack from {n, m}
Longest Common Substring

Given two strings. The task is to find the length of the longest common substring.

Question ID : 0707231144

Medium
Strings
DP

Problem : https://practice.geeksforgeeks.org/problems/longest-common-substring1452/1

Solution : https://youtu.be/_wP9mWNPL5w

Hint : (s1[i] != s2[j]) -> dp[i][j] = 0; return ans
Longest Palindromic Subsequence

Given a String, find the longest palindromic subsequence.

Question ID : 0707231324

Medium
DP
Strings

Problem : https://practice.geeksforgeeks.org/problems/longest-palindromic-subsequence-1612327878/1

Solution : https://youtu.be/6i_T5kkfv4A

Hint : longestPalindrom subSeq in s == longest common subSequence in (S,reverse of S)
Maximize the Confusion of an Exam

Given a string of T & F, and integer k, we can change T to F or F to T atmost K times, Return the maximum number of consecutive 'T's or 'F's in the answer

Question ID : 0707231417

Arrays
Medium

Problem : https://leetcode.com/problems/maximize-the-confusion-of-an-exam

Solution : https://youtu.be/gwhMrBPoEEw

Hint : maxConsecutive 1's , convert atmost K zeros
Min Insertions to make Palindrome

Given a string, find the minimum number of characters to be inserted to convert it to palindrome.

Question ID : 0707231451

Medium
DP
ReVisit
Strings

Problem : https://practice.geeksforgeeks.org/problems/form-a-palindrome1455/1

Solution : https://youtu.be/xPBLEj41rFU

Hint : length - longestPalindromSubSequence
Min Delete,Insertions

Given two strings str1 and str2. The task is to remove or insert the minimum number of characters from/in str1 so as to transform it into str2.

Question ID : 0707231510

Medium
DP
Strings

Problem : https://practice.geeksforgeeks.org/problems/minimum-number-of-deletions-and-insertions0209/1

Solution : https://youtu.be/yMnH0jrir0Q

Hint : delOp = n - lcs, insOp = m - lcs
Shortest Common Supersequence

Given two strings X and Y of lengths m and n respectively, find the length of the smallest string which has both, X and Y as its sub-sequences.

Question ID : 0707231518

Medium
DP
Strings

Problem : https://practice.geeksforgeeks.org/problems/shortest-common-supersequence0322/1

Solution : https://youtu.be/xElxAuBcvsU

Hint : n + m - lcs
Subsequence Counting

We are given two strings, ‘TEXT' and ‘S’. We have to calculate the no. of subsequences of ‘TEXT’, which are equal to ‘S’. Since the answer can be very large print it modulo (10^9)+7.

Question ID : 0707231916

Medium
DP
ReVisit
Strings

Problem : https://www.codingninjas.com/studio/problems/subsequence-counting_3755256

Solution : https://youtu.be/nVG7eTiD2bY

Hint : if(s1[i] == s2[j]) (i-1,j-1 or i-1,j) else (i-1,j)
Del Insert Replace

Given two strings s and t. Return the minimum number of operations required to convert s to t.
Insert a character
Remove any character
Replace any character.

Question ID : 0707232043

Medium
DP
ReVisit
Strings

Problem : https://practice.geeksforgeeks.org/problems/edit-distance3702/1

Solution : https://youtu.be/fJaKO8FbDdo

Hint : del(i-1, j) replace(i-1, j-1) insert(i, j-1)
Minimum Score of a Path Between Two Cities

You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads where roads[i] = [ai, bi, distancei].
The score of a path between two cities is defined as the minimum distance of a road in this path.
Return the minimum possible score of a path between cities 1 and n.

Question ID : 0807230739

Medium
Graphs

Problem : https://leetcode.com/problems/minimum-score-of-a-path-between-two-cities/

Solution : https://youtu.be/36sRR_lrgkI

Hint : djkstra's algo with queue
Divide Players Into Teams of Equal Skill

You are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player. Divide the players into n / 2 teams of size 2 such that the total skill of each team is equal.
The chemistry of a team is equal to the product of the skills of the players on that team.
Return the sum of the chemistry of all the teams

Question ID : 0807230747

Medium
Arrays
ReVisit

Problem : https://leetcode.com/problems/divide-players-into-teams-of-equal-skill/

Solution : https://youtu.be/B8pPSzKRFqk

Hint : sort arr, s = arr[0] + arr[n-1] | l, r [l + r != s] = -1
Wildcard Pattern Matching

Given two strings 'str' and a wildcard pattern 'pattern'.
‘ ? ’ – matches any single character
‘ * ’ – Matches any sequence of characters (including the empty sequence)

Question ID : 0807230756

Medium
DP
ReVisit
Strings

Problem : https://practice.geeksforgeeks.org/problems/wildcard-pattern-matching/1

Solution : https://youtu.be/ZmlQ3vgAOMo

Hint : [empty pattern != str] [empty str == stars pattern]
Buy and Sell Stock I

You are given an array/list 'prices' where the elements of the array represent the prices of the stock as they were yesterday and indices of the array represent minutes. Your task is to find and return the maximum profit you can make by buying and selling the stock. You can buy and sell the stock only once.

Question ID : 0807231041

Easy
Arrays

Problem : https://www.codingninjas.com/studio/problems/stocks-are-profitable_893405

Solution : https://youtu.be/excAOvwF_Wk

Hint : mini = prices[0], cost = prices[i] - mini,
mini = min(mini,prices[i])
Stock buy and sell segments

The cost of stock on each day is given in an array A[] of size N. Find all the segments of days on which you buy and sell the stock so that in between those days for which profit can be generated.

Question ID : 0807231055

Medium
Arrays
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/stock-buy-and-sell-1587115621/1

Hint : compare prices[i] with prices[i-1]
MaxProfit Stock Multiple Buy Sell

You are given the prices of stock for n number of days.Find the maximum profit that you can make by buying and selling stock any number of times as you can't proceed with other transactions if you hold any transaction.

Question ID : 0807231134

Medium
Arrays

Problem : https://practice.geeksforgeeks.org/problems/buy-stock-2/1

Solution : https://youtu.be/nGJmxkUJQGs

Hint : profit += (prices[sell] - prices[buy]), buy = -1
Detonate the Maximum Bombs

The bombs are represented array bombs[i] = [xi, yi, ri],
You may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.
Given the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb

Question ID : 0807231244

Medium
Graphs
ReVisit

Problem : https://leetcode.com/problems/detonate-the-maximum-bombs/

Solution : https://youtu.be/ajBbc7PrFzs

Hint : create adjLs by dis(x1y1 x2y2) ≤ r1*r1
Buy and Sell a Share at most n times

In daily share trading, a buyer buys shares in the morning and sells them on the same day. If the trader is allowed to make at most 2 transactions in a day, the second transaction can only start after the first one is complete (Buy->sell->Buy->sell). The stock prices throughout the day are represented in the form of an array of prices.
Given an array price of size N, find out the maximum profit that a share trader could have made.

Question ID : 0807231344

Medium
Arrays
ReVisit

Problem : https://practice.geeksforgeeks.org/problems/buy-and-sell-a-share-at-most-twice/1

Solution : https://youtu.be/-uQGzhYj8BQ

Hint : f(ind,canBuy,cap)
Longest Square Streak in an Array

You are given an integer array nums. A subsequence of nums is called a square streak if:
The length of the subsequence is at least 2, and after sorting the subsequence, each element (except the first element) is the square of the previous number.
Return the length of the longest square streak in nums, or return -1 if there is no square streak.

Question ID : 0807231847

Medium
Arrays

Problem : https://leetcode.com/problems/longest-square-streak-in-an-array

Solution : https://youtu.be/jAfSRlvGJwM

Hint : like longest consecutive numbers
Max Enemy Forts That Can Be Captured

You are given a array forts. forts[i] can be -1, 0, or 1 where:
-1 no fort, 0 enemy fort. 1 your fort.
Now you have decided to move your army from one of your forts at position i to an empty position j.
The army travels over enemy forts only. While moving the army, all the enemy forts that come in the way are captured.
Return the maximum number of enemy forts that can be captured. In case it is impossible to move your army, or you do not have any fort under your command, return 0.

Question ID : 0807231936

Medium
Arrays

Problem : https://leetcode.com/problems/maximum-enemy-forts-that-can-be-captured/

Solution : https://youtu.be/iXaboKjGTmM

Hint : maxZeros in btw -1, 1
Min Time to Collect All Apples in a Tree

Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at vertex 0 and coming back to this vertex.

Question ID : 0907230758

Medium
Trees
Graphs
ReVisit

Problem : https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree/

Solution : https://youtu.be/PE5qdXqgs6Y

Hint : dfs, childTime = 0 hasApple return 2, else return time + 2
Buy and Sell Stock with Cooldown

You are given a list of stock prices, ‘prices’. Where ‘prices[i]’ represents the price on ‘i’th day. Your task is to calculate the maximum profit you can earn by trading stocks if you can only hold one stock at a time. After you sell your stock on the ‘i’th day, you can only buy another stock on ‘i + 2’ th day or later.

Question ID : 0907230942

Medium
DP

Problem : https://www.codingninjas.com/studio/problems/best-time-to-buy-and-sell-stock-with-cooldown_3125969

Solution : https://youtu.be/IGIe46xw3YY

Hint : dp[canBuy][ind]
Buy and Sell Stock with Transaction Fee

Given 'N' number of days and an array 'PRICES' of size 'N' price of the chocolate each day. and variable 'FEE' fee for the transaction. Find the maximum profit.

Question ID : 0907230957

Medium
DP

Problem : https://www.codingninjas.com/studio/problems/best-time-to-buy-and-sell-stock-with-transaction-fee_3118974

Solution : https://youtu.be/k4eK-vEmnKg

Hint : sell = prices[ind] - fee
Printing Longest Increasing Subsequence

Find the Longest Increasing Subsequence of the array.

Question ID : 0907231136

Medium
DP
ReVisit

Problem : https://www.codingninjas.com/studio/problems/printing-longest-increasing-subsequence_8360670

Solution : https://youtu.be/IFfYfonAFGc

Hint : dp[i] = max(dp[i], 1 + dp[prev])
Divisible Set

Array of distinct numbers. Your task is to return the largest subset of numbers from ‘arr’, such that any pair of numbers ‘a’ and ‘b’ from the subset satisfies the following: a % b == 0 or b % a == 0.

Question ID : 0907231233

Medium
DP

Problem : https://www.codingninjas.com/studio/problems/divisible-set_3754960

Solution : https://youtu.be/gDuZwBW9VvM

Hint : sort arr -> dp[i] = 1 + dp[prev] , hash
Longest String Chain

string chain (str1, str2) means str2 = str1 + one character, find longest string chain

Question ID : 0907231407

Medium
DP

Problem : https://www.codingninjas.com/studio/problems/longest-string-chain_3752111

Solution : https://youtu.be/YY8iBaYcc4g

Hint : compare strings(i,prev) , prev + one char = i
Number of Longest Increasing Subsequence

Given an integer array ‘ARR’ of length ‘N’, return the number of longest increasing subsequences in it.

Question ID : 0907231537

Medium
DP
ReVisit

Problem : https://www.codingninjas.com/studio/problems/number-of-longest-increasing-subsequence_3751627

Solution : https://youtu.be/cKVl1TFdNXg

Hint : cnt(n,0) if (dp[i] == 1 + dp[prev]) cnt[prev] += cnt[prev]
Longest Bitonic Sequence

You are given an array/list 'ARR' consisting of 'N' positive integers. A subsequence of 'ARR' is called bitonic if it is first increasing and then decreasing.

Question ID : 0907231751

Medium
DP
ReVisit

Problem : https://www.codingninjas.com/studio/problems/longest-bitonic-sequence_1062688

Solution : https://youtu.be/y4vN0WNdrlg

Hint : LIS + reverseLIS - 1
Matrix Chain Multiplication

You will be given an array p[] of size n + 1. Dimension of matrix Ai is p[i - 1]*p[i]. You need to find minimum number of multiplications needed to multiply the chain.

Question ID : 0907231835

Hard
ReVisit
DP

Problem : https://www.codingninjas.com/studio/problems/matrix-chain-multiplication_624880

Solution : https://youtu.be/vRVfmbCFW7Y

Hint : f(arr,i,k) + f(arr, k+1,j) + arr[i-1] * arr[k] * arr[j]
Lexicographically Smallest Equivalent String

You are given two strings of the same length s1 and s2 and a string baseStr.
We say s1[i] and s2[i] are equivalent characters.
Return the lexicographically smallest equivalent string of baseStr by using the equivalency information from s1 and s2.

Question ID : 1007231025

Medium
Strings

Problem : https://leetcode.com/problems/lexicographically-smallest-equivalent-string/description/

Solution : https://youtu.be/J6NfkPSUecQ

Hint : disJoint set
Cost to Cut a Chocolate

You are given chocolate of ‘N’ length. The chocolate is labeled from 0 to ‘N’. You are also given an array ‘CUTS’ of size ‘C’, denoting the positions at which you can do a cut. The order of cuts can be changed. The cost of one cut is the length of the chocolate to be cut. Therefore, the total cost is the sum of all the cuts. Print the minimum cost to cut the chocolate.

Question ID : 1007231123

Hard
DP
ReVisit

Problem : https://www.codingninjas.com/studio/problems/cost-to-cut-a-chocolate_3208460

Solution : https://youtu.be/xwomavsC86c

Hint : sort cuts arr, chocoLength + (i,cut-1) + (cut+1,j)
Rod cutting problem

Given a rod of length ‘N’ units. The rod can be cut into different sizes and each size has a cost associated with it. Determine the maximum cost obtained by cutting the rod and selling its pieces.

Question ID : 1007231136

Medium
DP

Problem : https://www.codingninjas.com/studio/problems/rod-cutting-problem_800284

Hint : price[i-1] + f(length-i,prices)
Mining Diamonds

There are ‘N’ diamonds in a mine. The size of each diamond is given in the form of integer array ‘A’. If the miner mines a diamond, then he gets 'size of previous unmined diamond * size of currently mined diamond * size of next unmined diamond' number of coins.
find the max coins

Question ID : 1007231420

Hard
ReVisit
DP

Problem : https://www.codingninjas.com/studio/problems/mining-diamonds_4244494

Solution : https://youtu.be/Yz4LlDSlkns

Hint : add 1's to ends of arr,
select the last mine you want to blast, back ..
Boolean Expresion

You are given an expression ‘EXP’ in the form of a string where operands will be : (TRUE and FALSE) and operators will be : (AND, OR, XOR). Now you have to find the number of ways we can parenthesize the expression such that it will evaluate to TRUE.

Question ID : 1007231437

Hard
ReVisit
DP
Strings

Problem : https://www.codingninjas.com/studio/problems/boolean-evaluation_1214650

Solution : https://youtu.be/MM7fXopgyjw

Hint : k = i+1,k ≤ j-1,k+=2 -> lt,lf, rt,rf
Palindrome Partitioning

partition s such that every partition string is a palindrome.Return all possible palindrome partitioning of s.

Question ID : 1007231523

Medium
ReVisit
Recursion

Problem : https://www.codingninjas.com/studio/problems/palindrome-partitioning_626181

Solution : https://youtu.be/WBgsABoClE0

Hint : i = ind to n, palindrom(ind,i) -> f(i+1)
Palindrome Partitioning II

Given a string, make cuts in that string to make partitions containing substrings with size at least 1, and also each partition is a palindrome.Among all such valid partitions, return the minimum number of cuts to be made such that the resulting substrings in the partitions are palindromes.

Question ID : 1007231543

Hard
ReVisit
DP
Strings

Problem : https://www.codingninjas.com/studio/problems/palindrome-partitioning-ll_873266

Solution : https://youtu.be/_H8V5hJUGd0

Hint : front partition, check if palindrom(index,i) if -> next move to i + 1
Partition Array for Maximum Sum

You have to divide the array into some subarrays of length atmost k such that each element is present in exactly one of the subarrays.After partitioning all the elements of each subarray will be changed to the maximum element present in that subarray. You have to maximize the sum of all the elements after partitioning.

Question ID : 1007231604

Medium
Arrays
DP

Problem : https://www.codingninjas.com/studio/problems/partition-array-for-maximum-sum_3755255

Solution : https://youtu.be/PhWWJmaKfMc

Hint : front partition,
// (maximum upto i,ind)*(ind - i + 1) + f(ind+1,n,nums,k,dp)
Largest Rectangle in Histogram

Given an array of integers heights representing the histogram's bar height,return the area of the largest rectangle in the histogram.

Question ID : 1007231716

Hard
Arrays
ReVisit

Problem : https://leetcode.com/problems/largest-rectangle-in-histogram/

Solution : https://youtu.be/X0X6G-eWgQ8

Hint : rightSmall - leftSmall + 1 * heights[i]
Maximal Rectangle

Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.

Question ID : 1007231725

Medium
Arrays
Grid

Problem : https://leetcode.com/problems/maximal-rectangle/

Solution : https://youtu.be/tOylVCugy9k

Hint : histogram rectangle
Count Squares

Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.

Question ID : 1007231752

Hard
ReVisit
DP
Grid

Problem : https://leetcode.com/problems/count-square-submatrices-with-all-ones/

Solution : https://youtu.be/auS1fynpnjo

Hint : dp[i][j] = 0 -> 0, dp[i][j] = 1 -> 1 + min(dp[i-1,j-1] [i-1,j] [i,j-1] )
Connect n ropes with minimum cost

There are given n ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. We need to connect the ropes with minimum cost.

Question ID : 1107230901

Medium
Arrays

Problem : https://www.codingninjas.com/studio/problems/connect-n-ropes-with-minimum-cost_625783

Hint : use a priorityQueue and pop cost = smallTwo, push(sum)
Trapping Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

Question ID : 1107231030

Hard
ReVisit
Arrays

Problem : https://leetcode.com/problems/trapping-rain-water/

Solution : https://youtu.be/m18Hntz4go8

Hint : leftMax, rightMax
result[i] = min(leftMax,rightMax) water = max(0,resutl[i] - height[i])
Implement Queue using Arrays

Implement a simple queue using arrays.

Question ID : 1107231133

Easy
Queue
Arrays
ReVisit

Problem : https://www.codingninjas.com/studio/problems/implement-queue-using-arrays_8390825

Solution : https://youtu.be/M6GnoUDpqEE

Hint : front, rear
Stack using queue

Implement a Stack Data Structure specifically to store integer data using two Queues.

Question ID : 1107231146

Easy
Stacks
Queues

Problem : https://www.codingninjas.com/studio/problems/stack-using-queue_795152

Solution : https://youtu.be/jDZQKzEtbYQ

Hint : using q1,q2 -> st.push() -> push to q2, shift all ele from q1 to q2, swap q1 q2
Next Greater Element

Print the Next Greater Element(NGE) for every element.

Question ID : 1107231407

Arrays
Stacks
Medium
ReVisit

Problem : https://www.codingninjas.com/studio/problems/next-greater-element_670312

Solution : https://youtu.be/Du881K7Jtk8

Hint : while (st.empty() == false && st.top() ≤ arr[i]) st.pop()
Count Of Greater Elements To The Right

return a array of ans, where ans[i] = no of greater elements to the right of arr[i]

Question ID : 1107231428

Medium
Arrays

Problem : https://www.codingninjas.com/studio/problems/count-of-greater-elements-to-the-right_8365436

Hint : for( for() )
Asteroid Collision

For each element of the given array, its absolute value denotes the size of that asteroid, and its sign denotes the direction it moves in(+ve meaning right and -ve meaning left). 0 means moving left.
Whenever two asteroids collide, the smaller asteroid gets destroyed.If both asteroids are the same size, then both asteroids get destroyed. Two asteroids moving in the same direction never collide.
You are supposed to find the state of the asteroids after all collisions.

Question ID : 1107231514

Arrays
Medium

Problem : https://www.codingninjas.com/studio/problems/asteroid-collision_977232

Hint : while (+ve st.top() < -ve rock) pop
Sum of Subarray Minimums

let x be the minimum element of any contiguous subarray of ‘arr’.You need to return the sum of 'X' over all the contiguous subarrays of 'arr'.

Question ID : 1107231639

Medium
Arrays
ReVisit

Problem : https://www.codingninjas.com/studio/problems/sum-of-subarray-minimums_8365431

Hint : count leftEle >= i, rightEle > i, ans += i*l*r
LRU Cache Implementation

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

Question ID : 1107231927

Hard
ReVisit
LinkedList

Problem : https://leetcode.com/problems/lru-cache

Solution : https://youtu.be/xDEuM5qa0zg

Hint : Double LinkedList, most recent at head, least used at tail
LFU Cache

Design and implement a data structure for a Least Frequently Used (LFU) cache.

Question ID : 1207230801

LinkedList
Hard
ReVisit

Problem : https://leetcode.com/problems/lfu-cache/

Solution : https://youtu.be/0PSB9y8ehbk

Hint : freqMap of ListHead, keyMap of Nodes
The Celebrity Problem

There are ‘N’ people at a party. Each person has been assigned a unique id between 0 to 'N' - 1(both inclusive). A celebrity is a person who is known to everyone but does not know anyone at the party.

Question ID : 1207231142

Arrays
Medium
ReVisit

Problem : https://www.codingninjas.com/studio/problems/the-celebrity-problem_982769

Hint : for(i = 1 -> n), if (cand,i know) cand = i,
check wether cand can be celebrity
Longest Substring Without Repeating Characters

Given a string s, find the length of the longest substring without repeating characters.

Question ID : 1207231206

Medium
Strings

Problem : https://leetcode.com/problems/longest-substring-without-repeating-characters

Solution : https://youtu.be/qtVh-XEpsJo

Hint : set, l r , remove l++ , r++
Longest Substring with At Most K Distinct Characters

You are given a string 'str' and an integer ‘K’. Your task is to find the length of the largest substring with at most ‘K’ distinct characters.

Question ID : 1207231219

Strings
Medium

Problem : https://www.codingninjas.com/studio/problems/longest-substring-with-at-most-k-distinct-characters_2221410

Hint : map, if (mapSize > k) decrease l, if l == 0 erase map
Subarrays With At Most ‘K’ Distinct Values

You are given an array ‘ARR’ having ‘N’ integers. You are also given an integer ‘K’. The task is to count the number of subarrays that have at most ‘K’ distinct values.

Question ID : 1207231225

Medium
Arrays

Problem : https://www.codingninjas.com/studio/problems/subarrays-with-at-most-%E2%80%98k%E2%80%99-distinct-values_1473804

Hint : same as k distinct chars, map, mapSize > k - remove L erase ans += (r-l+1)
Longest Repeating Character Replacement

You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times.
Return the length of the longest substring containing the same letter you can get after performing the above operations.

Question ID : 1207231310

Strings
ReVisit
Medium

Problem : https://leetcode.com/problems/longest-repeating-character-replacement

Hint : maxCount -> max in FreqMap, maxLen = ans
Binary Subarrays With Sum

Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal.

Question ID : 1207231341

Medium
Arrays

Problem : https://leetcode.com/problems/binary-subarrays-with-sum

Hint : count leading zeros
Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

Question ID : 1207231459

Medium
Stack
ReVisit

Problem : https://leetcode.com/problems/min-stack/

Solution : https://youtu.be/V09NfaGf2ao

Hint : stack(val, min till now)
Queue Using Stack

Implement a queue data structure which follows FIFO(First In First Out) property, using only the instances of the stack data structure.

Question ID : 1207231533

Medium
ReVisit
Stacks
Queues

Problem : https://www.codingninjas.com/studio/problems/day-25-:-queue-using-stack_799482

Solution : https://youtu.be/3Et9MrMc02A

Hint : push( s1 -> s2, s1 push, s2 -> s1)
Infix To Postfix

Convert the given infix expression to postfix expression.

Question ID : 1307230817

Strings
Stacks
Medium

Problem : https://www.codingninjas.com/studio/problems/day-23-:-infix-to-postfix-_1382146

Solution : https://youtu.be/mg9yi6YuAVk

Hint : if op = ')' pop all to ans until '(',
Infix to Prefix

Given an infix expression, Your task is to convert the given infix expression to a prefix expression.

Question ID : 1307230833

Strings
Stacks
Medium
ReVisit

Solution : https://takeuforward.org/data-structure/infix-to-prefix/

Hint : reverse infix change brackets, prefix = reverse postfix(reverse infix)
Postfix To Infix

Convert postfix expression to infix notation.

Question ID : 1307230911

Strings
Stacks
Medium

Problem : https://www.codingninjas.com/studio/problems/postfix-to-infix_8382386

Solution : https://youtu.be/MuF5p8-oWc8

Hint : if (op = operator), exp2 = st.pop, exp1 = st.pop, st.push(1 + op + 2)
Prefix To Infix

Convert prefix expression to infix notation.

Question ID : 1307231018

Strings
Stacks
Medium
ReVisit

Problem : https://www.codingninjas.com/studio/problems/prefix-to-infix_1215000

Solution : https://youtu.be/5B6jw4wOJR0

Hint : create infix of reverse postfix, reverse ans , reverse brackets
Build Binary Expression Tree From Infix Expression

You are given a string ‘S’, an infix expression that has operands, operators and parentheses ‘(‘ and ‘)’.
You need to return the binary expression tree, whose inorder traversal is the same as ‘S’.

Question ID : 1307231155

Hard
Stacks
Trees
Strings

Problem : https://www.codingninjas.com/studio/problems/build-binary-expression-tree-from-infix-expression_1281854

Hint : create postFix, implement postFix to infix
instead of adding as string do opLeft = 2nd st.top , opRight = 1st st.top, st.push op
Trie Implementation

Trie / prefix Tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.

Question ID : 1307231417

Tries
Medium
Strings

Problem : https://leetcode.com/problems/implement-trie-prefix-tree/

Solution : https://youtu.be/dBGUmUQhjaM

Hint : for insert add to root move next
Implement Trie ll

Implement a data structure ”TRIE” from scratch.
insert(“WORD”)
countWordsEqualTo(“WORD”)
countWordsStartingWith(“PREFIX”)
erase(“WORD”)

Question ID : 1307231513

Hard
Tries
ReVisit
Strings

Problem : https://www.codingninjas.com/studio/problems/implement-trie_1387095

Solution : https://youtu.be/K5pcpkEMCN0

Hint : cntEndWith, cntPrefix
Complete String

A string is called a complete string if every prefix of this string is also present in the array ‘A’. Ninja is challenged to find the longest complete string in the array ‘A’.If there are multiple strings with the same length, return the lexicographically smallest one and if no string exists, return "None".

Question ID : 1307231552

Hard
Tries
Strings

Problem : https://www.codingninjas.com/studio/problems/complete-string_2687860

Solution : https://youtu.be/AWnBa91lThI

Hint : construct trie -> for each word -> searchOfStr + if(node->getEnd() == 0) return false
Count Distinct Substrings

Given a string 'S', you are supposed to return the number of distinct substrings(including empty substring) of the given string. You should implement the program using a trie.

Question ID : 1307231647

Medium
ReVisit
Strings
Tries

Problem : https://www.codingninjas.com/studio/problems/count-distinct-substrings_985292

Solution : https://youtu.be/RV0QeTyHZxo

Hint : i = 0 to n, trie->insert(str(i,n))
cnt++ if node not contain ch
Permutations

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

Question ID : 1307232027

Medium
Arrays

Problem : https://leetcode.com/problems/permutations

Solution : https://youtu.be/f2ic2Rsc9pU

Hint : {vec,i} -> swap i with next indexs -> recursive i + 1
Bitwise Basic Operations

You will be given three functions , getXOR , getBit, setBit

Question ID : 1307230811

Bits
Easy
ReVisit

Problem : https://www.codingninjas.com/studio/problems/bitwise-basic-operations_8382552

Solution : https://youtu.be/5iyuU4hQFrw

Hint : get(1 & (num >> i)), set(num | (1 << i)), erase(num & (~(1 << i)))
Set The Rightmost Unset Bit

The problem is to find the rightmost bit of a non-negative number 'N' that is currently unset (i.e., has a value of 0) in its binary representation and set it to 1.

Question ID : 1307231013

Bits
Medium

Problem : https://www.codingninjas.com/studio/problems/set-the-rightmost-unset-bit_8160456

Hint : while (x != 0,cnt) {if (x & 1 == 0) -> j = cnt, j is the rightMost unsetBit }
Flip Bits

Given two integers start and goal, return the minimum number of bit flips to convert start to goal.

Question ID : 1307231153

Bits
Easy

Problem : https://www.codingninjas.com/studio/problems/flip-bits_8160405

Hint : x = A ^ B, count setBits in x
Permutations II

Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.

Question ID : 1307231354

Medium
Arrays

Problem : https://leetcode.com/problems/permutations-ii

Hint : set, ind swap unique vec[j],
Heap Sort

Given an array of integers nums, sort the array in ascending order and return it.

Question ID : 1607231006

Medium
ReVisit
Sorting
Arrays

Problem : https://leetcode.com/problems/sort-an-array/

Solution : https://youtu.be/MMTQz-G8e-I

Hint : buildHeap -> [i = n/2 - 1 to 0 heapify]
Minimum Add to Make Parentheses Valid

You are given a parentheses string s. In one move, you can insert a parenthesis at any position of the string.Return the minimum number of moves required to make s valid.

Question ID : 1607231020

Medium
Strings

Problem : https://leetcode.com/problems/minimum-add-to-make-parentheses-valid

Hint : count openBrackets, closedBracket -> open--; if (closedBrackets noOpenBracekt present) => moves++; last moves += open
Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)

Question ID : 1607231039

Medium
LinkedList

Problem : https://leetcode.com/problems/swap-nodes-in-pairs

Hint : if (l < 2 return )
Add Binary

Given two binary strings a and b, return their sum as a binary string.

Question ID : 1607231926

Medium
Strings

Problem : https://leetcode.com/problems/add-binary

Hint : a + b + carry,
Partition List

Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You should preserve the original relative order of the nodes in each of the two partitions.

Question ID : 1607232013

Medium
LinkedList

Problem : https://leetcode.com/problems/partition-list

Hint : merge lists, dummy1 , dummy2
Max Points on a Line

Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.

Question ID : 1707230839

Hard
Arrays

Problem : https://leetcode.com/problems/max-points-on-a-line/

Hint : for i, j , check if it is vertical line else mp[slope]++, current max of map
Median of data Stream

Question ID : 2507231142

Hard
ReVisit
Queue

Problem : https://leetcode.com/problems/find-median-from-data-stream

Solution : https://youtu.be/EcNbRjEcb14

Hint : while insert, make sure sizes of queues differ by atmost 1
Nearest Exit from Entrance in Maze

You are given an m x n matrix maze with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze.
An exit is defined as an empty cell that is at the border of the maze.
Return the number of steps in the shortest path from the entrance to the nearest exit, or -1 if no such path exists.

Question ID : 2507231431

Medium
Graphs
Grid

Problem :

Solution :

Hint : bfs from entrance, if cell is in border and its open return dist
Maximum Number of Events That Can Be Attended

You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.
You can attend an event i at any day d where startTimei ≤ d ≤ endTimei. You can only attend one event at any time d.
Return the maximum number of events you can attend.

Question ID : 2607231206

Arrays
Medium
ReVisit

Problem : https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended

Solution : https://youtu.be/ABH9cRhwmlg

Hint : sort based on end, equal end day => start day, lower_bound(set)
Longest Increasing Path

Given an m x n integers matrix, return the length of the longest increasing path in matrix.
From each cell, you can either move in four directions: left, right, up, or down.

Question ID : 2707231004

Hard
ReVisit
DP
Grid

Problem : https://leetcode.com/problems/longest-increasing-path-in-a-matrix

Hint : dp[r1][c1]
Meeting Rooms III

There are n rooms 0 to n - 1.
You are given a array meetings will be held during the half-closed time interval [starti, endi).
Each meeting will take place in the unused room with the lowest number.
If there are no available rooms, the meeting will be delayed until a room becomes free. The delayed meeting should have the same duration as the original meeting.
When a room becomes unused, meetings that have an earlier original start time should be given the room.
Return the number of the room that held the most meetings. If there are multiple rooms, return the room with the lowest number

Question ID : 2607231136

ReVisit
Hard
Queue

Problem : https://leetcode.com/problems/meeting-rooms-iii

Hint : sort on starting time, pq of {endTime, room}, pq of unused rooms , mp [ count of usage of room]

Hardness :

Topic :

ALL Sorting Arrays LinkedList Binary Search Strings Recursion Stack - Queue Greedy Trees BST Graphs DP window Grid Tries Bits

solution :

SYNTAX.c++ OOPS.c++ DSA.c++ COLD.c++