Tip 1: Master the "systems" perspective of DSA.
Tip 2: Deep dive into OS and networking fundamentals.
Tip 1: Go through all the projects mentioned in your resume thoroughly.
Tip 2: If you have mentioned OS or Networks as courses, then study them thoroughly.



• Fill any of the jugs entirely with water.
• Empty any of the jugs.
• Pour water from one jug into another till the other jug is full, or the first jug itself is empty.
In order to measure 2 litres from jugs of 4 and 6 litres we can follow the following steps-
• Fill 6-litres jugs to its maximum capacity.
• Pour water from 6-litres jug to the jug with 4-litres capacity.
• Pour water from 6-litres jug to the jug with 4-litres capacity.
Logic Steps
1) Data Structuring: Create a list of objects or a vector of tuples to store each drink's attributes: coffee_qty, chocolate_qty, and its original_index (1-indexed).
2) Define Comparator: Implement a sorting function based on the prioritized rules:
Rule 1 (Pure Coffee): If one drink has chocolate == 0 and the other doesn't, the one with 0 chocolate ranks higher.
Rule 2 (Coffee Quantity): If both are "pure" or both are "mixed," the one with the higher coffee_qty ranks higher.
Rule 3 (Chocolate Quantity): If coffee quantities are equal, the one with the higher chocolate_qty ranks higher.
Rule 4 (Input Order): If all quantities are equal, the drink that appeared earlier in the input ranks higher.
3) Query Handling: After sorting, the drink at sorted_list[r-1] is the answer for rank r. Store the results in an array to return


Input: ‘N’ = 5, ‘K’ = 1, ‘STR’ = “10101”
Output: 01110
In this case, the indices satisfying the condition of ‘STR[i-1] = STR[i+1]’ are ‘1’, ‘2’, and ‘3’. Hence the string ‘STR’ after applying the given operation for ‘K(=1)’ times will be “01110”.
Logic Steps
Prefix-Flip Logic: To make a string uniform using prefix flips, an operation is required at index i if S[i]=S[i+1]. The total operations for a fixed string is the count of adjacent mismatches plus a potential final flip to match the target (0 or 1).
Contribution Technique: Instead of generating all 2k strings, calculate how much each adjacent pair (S[i],S[i+1]) contributes to the total sum.
Handling '?' Pairs:
Fixed Pair (e.g., '01'): Contributes 1×2k to the sum.
One '?' (e.g., '0?'): The '?' will be '1' in half the cases (2k−1), causing a mismatch.
Two '?'s ('??'): In the four combinations (00, 01, 10, 11), two result in mismatches, contributing 2×2k−2 per pair.
Modulo Arithmetic: Perform all additions and multiplications modulo 109+7.



All arrival and leaving times are distinct.
Logic Steps
Search Space: The possible answer (the maximized minimum rating) lies between the minimum and maximum values present in the matrix.
Binary Search: Pick a middle rating X. Check if it's possible to select (n−2) products such that every customer has at least one product with a rating ≥X.
Feasibility Check (The "Check" Function):
For each product, create a bitmask (or boolean array) representing which customers are "satisfied" (rating ≥X) by that product.
Since you must pick n−2 products, it is easier to think about the 2 products you leave out.
You need to find if there exist products such that their union covers all n customers. If m is large but n is small, you can use bitmasks. If n is large, look for a product that covers many customers and check if the remaining gaps can be filled.
Maximize X: If X is feasible, try a higher value; otherwise, try lower.
Hybrid Search: Consider a sorted list: 12 43 65 78 98 101 187. If a "Hsearch" technique compares the middle element first and then searches linearly in the appropriate half, how many comparisons are made to find the number 187?
Tip 1:Solve these types of questions from the internet.



Infix notation is a method of writing mathematical expressions in which operators are placed between operands. For example, "a + b" represents the addition of a and b.
Prefix notation is a method of writing mathematical expressions in which operators are placed before the operands. For example, "+ a b" represents the addition of a and b.
Expression contains lowercase English letters, ‘+’, ‘-’, ‘*’, and ‘/’.
Input: /-ab+-cde
Output: ((a-b)/((c-d)+e))
Explanation:
In this test case, there are four operators ‘/’, ‘-’, ‘+’, ‘-’.
Prefix expression: /-ab+-cde.
The operator between ‘a’ and ‘b’ is ‘-’. Resulting expression: /(a-b)+-cde.
The operator between ‘c’ and ‘d’ is ‘-’. Resulting expression: /(a-b)+(c-d)e.
The operator between ‘c-d’ and ‘e’ is +. Resulting expression: /(a-b)((c-d)+e).
The operator between ‘a-b’ and ‘((c-d)+e)’ is ‘/’. Resulting expression: ((a-b)/((c-d)+e)).
Geometry & Patterns: Some balls are arranged in rows to form an equilateral triangle (the 1st row has 1 ball, the 2nd has 2, and so on). If 472 balls are added, they can form a square in which each side has 7 balls fewer than the side of the original triangle. Find the initial number of balls.
Probability: Rajesh and Ramesh each have a 5, 10, and 20 paise coin. They randomly select one. If the sum is odd, Rajesh wins; if even, Ramesh wins. Find the probability that Rajesh wins exactly one odd and one even coin in the first two games.



For a given string “BaaB”
3 possible palindrome partitioning of the given string are:
{“B”, “a”, “a”, “B”}
{“B”, “aa”, “B”}
{“BaaB”}
Every substring of all the above partitions of “BaaB” is a palindrome.
Given N≤5000, an O(N2) approach is efficient enough. Here are the steps to solve it:
Step 1: Precompute Palindromes
Before solving the partitioning part, you need to know if any substring s[i…j] is a palindrome.
Create a 2D boolean table isPal[N][N] where isPal[i][j] is true if s[i…j] is a palindrome.
Base cases: All single characters are palindromes (isPal[i][i] = true). Two adjacent identical characters are palindromes (isPal[i][i+1] = (s[i] == s[i+1])).
Transitions: For length L>2: isPal[i][j] = (s[i] == s[j] && isPal[i+1][j-1]).
This takes O(N2) time.
Step 2: Define the DP State
Let dp[i] be the maximum number of valid partitions possible for the prefix s[0…i−1].
Initialize dp[0] = 0 (zero partitions for an empty string).
Initialize all other dp[i] = -1 (to represent that a valid partition ending at i hasn't been found yet).
Step 3: Transitions
Iterate through the string from i=1 to N. For each i, check all possible previous partition points j:
For each j such that 0≤j≤i−k:
Check if the current segment s[j…i−1] is a palindrome using your isPal table.
Check if the segment length is ≥k (this is handled by the loop constraint j≤i−k).
Check if the prefix ending at j was successfully partitioned (dp[j] != -1).
Update Rule: If all conditions are met:
dp[i]=max(dp[i],dp[j]+1)
Step 4: Final Answer
The answer will be stored in dp[N]. If dp[N] is still -1, it means the string cannot be partitioned according to the rules.
Design a system where riders can book a cab and drivers can accept or reject rides. The system should handle matching a rider with the nearest available driver, calculating the fare based on distance and vehicle type, and managing the ride lifecycle (Requested, In Progress, Completed).

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which data structure is used to implement a DFS?