Vadish Chhatwaldukex.hashnode.dev·Jul 19, 2024DSA Journey: From Newbie to AceHectic Days Life has become really hectic these days. My college is literally torturing all students. Last, I wrote about how my mentor motivated the class to stay focused on DSA. It's been 2 days since then. I think the time for my continuous sittin...DSA
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 12, 2024Maximum Score From Removing SubstringsProblem Link https://leetcode.com/problems/maximum-score-from-removing-substrings/description/ Approach If x > y we have to focus on making the "ab" pairs more than any other pair, so we will do the same in the first pass Once all the pairs are don...DailyDoseOfDSA
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 11, 2024Reverse Substrings Between Each Pair of ParenthesesProblem Link Click Here Approach First we will store the characters other than parenthesis because we don't want parenthesis in our answer. As soon as we encounter an opening bracket we will store it's index In the vector As all the parenthesis ar...DSA
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 10, 2024Crawler Log Folder (LeetCode)Problem Link Click Here Intuition see whenever we write the commandcd /foldernameand suppose you are in the root directory so once this command is executed, how many steps you need to go back to root directory? 1 step right you will just peform cd .....leetcode
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 9, 2024Average Waiting time (Simulation based question)Problem link Click here Approach Initially, when the chef is not doing anything and a customer arrives, the waiting time for the customer to get a particular dish ordered is nothing but just the preparation time. Now, let's suppose the chef is prep...ujjwalsharma
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 8, 2024Josephus AlgorithmProblem Link Click Here Approaches Approach 1 (Brute force) we will create one array/vector to store the values from 1 to n, representing the sequence of each person As given in the question we will remove one person from the array and move forward...josephus algoritm
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 7, 2024Water bottle Problem (Leetcode POTD)Problem Link Click Here Approach We need to calculate the maximum number of full water bottles we can consume right so let's consider one test case Total filled bottled = 15, Exchange Rate = 4 So initially we will consume 15 bottles now these bott...leetcode
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 6, 2024Two sum problem (The foundation)NOTE - please read this article properly and solve the question twice once on paper and then on leetcode because this question serves as the foundation for the upcoming question In this category that is, 3 sum and 4 sum Question Click Here Approaches...two-sum-problem
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 4, 2024Moore's Voting AlgorithmWorking Let the initial length be 1, because we are considering the first element as the initial element in our count. Move forward in the array and if the same element appears again, then increase the count by 1; if not, then decrease the count by...Programming Blogs
Ujjwal Sharmaujjwalsharma.hashnode.dev·Jul 3, 2024Rotate the array by K placesQuestion link - https://leetcode.com/problems/rotate-array/ Approach 1 Brute Force approach Create a temporary vector that will store the number of arrays present to be rotated. Now we need to normalize the rotation because for example if the size ...DailyDoseOfDSA