KEMBAR78
Zero To Advance: 30 Days Challenge | PDF
0% found this document useful (0 votes)
84 views33 pages

Zero To Advance: 30 Days Challenge

This 30-day document provides a daily challenge to practice data structures and algorithms (DSA) concepts. Each day focuses on 1-2 problems and provides practice questions. The goal is to develop problem solving abilities to solve new problems. Disclaimer notes everyone learns uniquely and what matters most is developing problem solving skills.

Uploaded by

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

Zero To Advance: 30 Days Challenge

This 30-day document provides a daily challenge to practice data structures and algorithms (DSA) concepts. Each day focuses on 1-2 problems and provides practice questions. The goal is to develop problem solving abilities to solve new problems. Disclaimer notes everyone learns uniquely and what matters most is developing problem solving skills.

Uploaded by

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

Zero to Advance

in
DSA

30 Days Challenge
*Disclaimer*
Everyone learns uniquely.

What matters is developing the problem


solving ability to solve new problems.

This Doc will help you with the same.

1
Day 1

Given an array of integers num and an integer target, return


indices of the two numbers such that they add up to target.

Practice

Given an integer array nums, find the subarray with the


largest sum, and return its sum.

Practice
Practice

2
Day 2

Given an array nums with n objects colored red, white, or


blue, sort them in-place so that objects of the same color are
adjacent, with the colors in the order red, white, and blue.

Practice
Practice

You are given an integer array height of length n. There are


n vertical lines drawn such that the two endpoints of the ith
line are (i, 0) and (i, height[i]). Find two lines that
together with the x-axis form a container, such that the
container contains the most water. Return the maximum
amount of water a container can store.

Practice
Practice

3
Day 3

You are given an array of prices where prices[i] is the


price of a given stock on an ith day. You want to maximise
your profit by choosing a single day to buy one stock and
choosing a different day in the future to sell that stock.
Return the maximum profit you can achieve from this
transaction. If you cannot achieve any profit, return 0.

Practice
Practice

Given an array nums of n integers, return an array of all the


unique quadruplets [nums[a], nums[b], nums[c],
nums[d]] such that:

0 <= a, b, c, d < n

a, b, c, and d are distinct.

nums[a] + nums[b] + nums[c] + nums[d] ==


target

Practice
Practice

4
Day 4

Write a function that reverses a string. The input string is


given as an array of characters s. You must do this by
modifying the input array in-place with O(1) extra memory.

Practice
Practice

Given a string s, sort it in decreasing order based on the


frequency of the characters. The frequency of a character is
the number of times it appears in the string.

Return the sorted string. If there are multiple answers, return


any of them.

Practice
Practice

5
Day 5

Given two strings s1 and s2, return true if s2 contains a


permutation of s1, or false otherwise.

In other words, return true if one of s1's permutations is the


substring of s2.

Practice
Practice

Given a string s, partition s such that every

Substring of the partition is a Palindrome. Return all possible


palindrome partitioning of s.

Practice
Practice

6
Day 6

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.

Practice
Practice

A phrase is a palindrome if, after converting all uppercase


letters into lowercase letters and removing all non-
alphanumeric characters, it reads the same forward and
backward. Alphanumeric characters include letters and
numbers.

Given a string s, return true if it is a palindrome, or false


otherwise.

Practice
Practice

7
Day 7

Given the head of a linked list and an integer val, remove all
the nodes of the linked list that has Node.val == val, and
return the new head.

Practice
Practice

Given the head of a singly linked list, reverse the list, and
return the reversed list.

Practice
Practice

8
Day 8

Given an integer array nums of unique elements, return all


possible

Subsets (the power set).

The solution set must not contain duplicate subsets. Return


the solution in any order.

Practice
Practice

Given n pairs of parentheses, write a function to generate all


combinations of well-formed parentheses.

Practice
Practice

9
Day 9

Practice
Practice

Given an unsorted integer array nums, return the smallest


missing positive integer.

You must implement an algorithm that runs in O(n) time and


uses constant extra space.

Practice
Practice

10
Day 10

Given an m x n matrix, return all elements of the matrix


in spiral order.

Practice
Practice

Determine if a 9 x 9 Sudoku board is valid. Only the filled


cells need to be validated according to the following rules1

+ Each row must contain the digits 1-9 without repetition.-


+ Each column must contain the digits 1-9 without repetition.-
+ Each of the nine 3 x 3 sub-boxes of the grid must contain
the digits 1-9 without repetition.

Practice
Practice

11
Day 11

Given an m x n grid of characters board and a string word,


return true if word exists in the grid.

The word can be constructed from letters of sequentially


adjacent cells, where adjacent cells are horizontally or
vertically neighboring. The same letter cell may not be used
more than once.

Practice
Practice

Given an m x n matrix board containing 'X' and 'O',


capture all regions that are 4-directionally surrounded by
'X'.

A region is captured by flipping all 'O's into 'X's in that


surrounded region.

Practice
Practice

12
Day 12

Given the root of a binary tree, flatten the tree into a "linked
list":

The "linked list" should use the same TreeNode 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.

Practice
Practice

Given elements as nodes of the two linked lists. The task is to


multiply these two linked lists, say L1 and L2.

Practice
Practice

13
Day 13

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.

Practice
Practice

You are given the heads of two sorted linked lists list1 and
list2.

Merge the two lists in a one sorted list. The list should be
made by splicing together the nodes of the first two lists.

Return the head of the merged linked list.

Practice
Practice

14
Day 14

You are given the head of a singly linked-list. The list can be
represented as: L0 → L1 → … → Ln - 1 → Ln

Reorder the list to be on the following form:

L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → …

You may not modify the values in the list's nodes. Only nodes
themselves may be changed.

Practice
Practice

Practice
Practice

15
Day 15

Given an array nums containing n distinct numbers in the


range [0, n], return the only number in the range that is
missing from the array.

Practice
Practice

Given an integer n, return an array ans of length n + 1 such


that for each i (0 <= i <= n), ans[i] is the number of
1's in the binary representation of i.

Practice
Practice

16
Day 16

Given an array of integers heights representing the


histogram's bar height where the width of each bar is 1,
return the area of the largest rectangle in the histogram.

Practice
Practice

Practice
Practice

17
Day 17

Practice
Practice

Practice
Practice

18
Day 18

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.

Practice
Practice

Given an array of integers temperatures represents the


daily temperatures, return an array answer such that
answer[i] is the number of days you have to wait after the
ith day to get a warmer temperature. If there is no future
day for which this is possible, keep answer[i] == 0
instead.

Practice
Practice

19
Day 19

You are given an array of integers nums, there is a sliding


window of size k which is moving from the very left of the
array to the very right. You can only see the k numbers in the
window. Each time the sliding window moves right by one
position.

Return the max sliding window.

Practice
Practice

Practice
Practice

20
Day 20

Practice
Practice

Practice
Practice

21
Day 21

Given the root of a binary search tree, and an integer k,


return the kth smallest value (1-indexed) of all the values of
the nodes in the tree.

Practice
Practice

Given the root of a binary tree, return the level order


traversal of its nodes' values. (i.e., from left to right, level by
level).

Practice
Practice

22
Day 22

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.Return the total sum of all root-to-leaf
numbers. Test cases are generated so that the answer will fit
in a 32-bit integer.

Practice
Practice

Practice
Practice

23
Day 23

Practice
Practice

Given an array of strings strs, group the anagrams together.


You can return the answer in any order.

Practice
Practice

24
Day 24

You are given an array of k linked-lists lists, each linked-list is


sorted in ascending order.

Merge all the linked-lists into one sorted linked-list and


return it.

Practice
Practice

Practice
Practice

25
Day 25

Given an m x n binary matrix mat, return the distance of the


nearest 0 for each cell.

The distance between two adjacent cells is 1.

Practice
Practice

An image is represented by an m x n integer grid image


where image[i][j] represents the pixel value of the
image.

You are also given three integers sr, sc, and color. You
should perform a flood fill on the image starting from the
pixel image[sr][sc].

Practice
Practice

26
Day 26

Given an m x n 2D binary grid which represents a map of


'1's (land) and '0's (water), return the number of islands.

An is surrounded by water and is formed by connecting


adjacent lands horizontally or vertically. You may assume all
four edges of the grid are all surrounded by water.

Practice
Practice

Practice
Practice

27
Day 27

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. You may not move diagonally or move
outside the boundary (i.e., wrap-around is not allowed).

Practice
Practice

You are given a network of n nodes, labeled from 1 to n. You


are also given times, a list of travel times as directed edges
times[i] = (ui, vi, wi), where ui is the source node,
vi is the target node, and wi is the time it takes for a signal
to travel from source to target.

We will send a signal from a given node k. Return the


minimum time it takes for all the n nodes to receive the
signal. If it is impossible for all the n nodes to receive the
signal, return -1.

Practice
Practice
28
Day 28

Given an integer array nums, find a subarray that has the


largest product, and return the product.

Practice
Practice

Given an integer array nums, return true if you can partition


the array into two subsets such that the sum of the elements
in both subsets is equal or false otherwise.

Practice
Practice

29
Day 29

There is a robot on an m x n grid. The robot is initially


located at the top-left corner (i.e., grid[0][0]). The robot
tries to move to the bottom-right corner (i.e., grid[m - 1]
[n - 1]). The robot can only move either down or right at
any point in time.

Given the two integers m and n, return the number of


possible unique paths that the robot can take to reach the
bottom-right corner.

Practice
Practice

Given two strings word1 and word2, return the minimum


number of operations required to convert word1 to word2.

You have the following three operations permitted on a


word:

Insert a character

Delete a character

Replace a character

Practice
Practice
30
Day 30

You are given an integer array coins representing coins of


different denominations and an integer amount representing
a total amount of money.

Return the fewest number of coins that you need to make up


that amount. If that amount of money cannot be made up by
any combination of the coins, return -1.

You may assume that you have an infinite number of each


kind of coin.

Practice
Practice

Given an integer array nums, return true if you can partition


the array into two subsets such that the sum of the elements
in both subsets is equal or false otherwise.

Practice
Practice

31
Why

Bosscoder?
1000+ Alumni placed at Top
Product-based companies.

More than 136% hike for every 



2 out of 3 working professional.

Average package of 24LPA.

Explore More

You might also like