top of page
Blog
Reformat Date (LeetCode 1507): Parse Once, Format Once
Reformat Date (LeetCode 1507): Parse Once, Format Once Given a date like 20th Oct 2052, return it as 2052-10-20. Days carry a suffix (st, nd, rd, th) and months are three-letter names. Split into three parts The input always has exactly three space-separated tokens. The day is the token without its last two characters, the month comes from a lookup table, and the year is used as-is. def reformat_date(date): months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct'
Nov 41 min read
Consecutive Characters (LeetCode 1446): Tracking the Longest Run
The power of a string is the length of its longest substring made of a single repeated character. Return it. This is the classic 'run length' scan that shows up inside many harder problems. Approach Walk the string keeping the length of the current run. When the character matches the previous one, extend the run; otherwise reset it to 1. Track the best run seen so far. def max_power(s): best = cur = 1 for i in range(1, len(s)): cur = cur + 1 if s[i] == s[i - 1
Nov 41 min read
Image Smoother (LeetCode 661): Clean Neighbor Loops
For each cell of a grayscale image, replace it with the floor of the average of itself and its up to eight neighbors. Idea Loop over the 3x3 block around each cell, skip coordinates outside the grid, and count how many cells you actually used. def imageSmoother(img): m, n = len(img), len(img[0]) out = [[0] * n for _ in range(m)] for i in range(m): for j in range(n): total = count = 0 for r in range(i - 1, i + 2): for c in range(j - 1, j + 2): if 0 <= r < m and 0 <= c < n: tot
Nov 31 min read
Fair Candy Swap (LeetCode 888): One Equation and a Hash Set
Alice and Bob each have boxes of candy with different totals. They want to swap exactly one box each so their totals become equal. The problem guarantees an answer exists. Turn it into algebra Let the sums be A and B. If Alice gives x and receives y, then A - x + y = B - y + x, which simplifies to y = x + (B - A) / 2. So for each box x that Alice owns, you only need to know whether Bob owns the box x + delta, where delta = (B - A) / 2. Code def fair_candy_swap(alice, bob): de
Nov 31 min read
Union of intervals vs. meeting rooms: two greedy patterns
Interval problems show up constantly in coding interviews, and two of the most common ones look similar but ask different questions. Merging overlapping intervals asks what the union looks like. Meeting rooms asks how many things happen at once. Both yield to greedy thinking once you pick the right sort order. Pattern one: union of intervals. Sort the intervals by start time. Keep a current interval, and for each next interval, if its start is at or before the current end, ex
Nov 32 min read
Next Greater Element II: The Circular Monotonic Stack
Next Greater Element II (LeetCode 503) gives a circular array and asks, for each element, the first larger value you meet walking forward and wrapping around. Brute force is O(n^2); the interviewer wants O(n). The stack idea Keep a stack of indices whose answer is still unknown. Values on the stack are decreasing from bottom to top. When a new value is larger than the value at the top index, that new value is the answer for the top index, so pop and record it. Keep popping wh
Nov 22 min read
Hand of Straights: Greedy With a Sorted Counter
Hand of Straights asks whether a hand of cards can be split into groups of size W where each group is W consecutive values. It looks like a search problem, but a greedy rule solves it in O(n log n). The greedy rule Take the smallest card still in the hand. It cannot be in the middle or end of a group, because nothing smaller is left to come before it. So it must start a group, and that group must be x, x+1, ..., x+W-1. Remove those cards and repeat. Code from collections impo
Nov 21 min read
Meeting Rooms Problems in Coding Interviews: Sort, Then Sweep
The "meeting rooms" family is a favorite at big tech phone screens. The questions look different, but they all reduce to sorting intervals and sweeping through time. Meeting Rooms I: can one person attend everything? Sort by start time, then check whether any meeting starts before the previous one ends. O(n log n) for the sort, O(1) extra space. Ask whether a meeting ending at 10:00 conflicts with one starting at 10:00; usually it does not. Meeting Rooms II: minimum number of
Nov 11 min read
How to Answer "What Is Your Notice Period?" in an Interview
It sounds like an administrative question, but recruiters use it to judge whether your timeline fits the role and whether you will leave your current employer professionally. A clear, honest answer helps you; a vague one can cost you an offer. Know your facts before the call Check your contract for the exact notice period, any garden leave clause, unused vacation that might shorten your last day, and any non-compete. Saying "I think it's about a month" sounds unprepared. A si
Nov 12 min read
How to Answer "Tell Me About a Time You Mentored Someone"
How to Answer "Tell Me About a Time You Mentored Someone" This question appears in interviews for senior individual contributor roles, team lead roles, and even junior roles where the company values knowledge sharing. The interviewer wants to know whether you make the people around you better, and how. What they're really evaluating Patience and communication: can you explain things at the right level? Judgment: do you know when to give answers and when to let people struggle
Nov 12 min read


How to Define and Pursue Career Objectives
In today's fast-paced world, having clear career objectives is essential for professional growth and satisfaction. Whether you're just starting out or looking to make a change, understanding how to define and pursue your career goals can set you on a path to success. This guide will walk you through the steps to identify your objectives, create a plan, and stay motivated throughout your journey. Understanding Career Objectives Career objectives are specific goals that guide y
Nov 14 min read


Top Strategies to Achieve Your Career Aspirations
In today's fast-paced world, achieving your career aspirations can feel like a daunting task. With the constant evolution of industries and the competitive job market, it’s essential to have a clear strategy to navigate your career path effectively. This blog post will explore practical strategies that can help you reach your professional goals, whether you are just starting out or looking to make a significant career change. Define Your Career Goals The first step in achievi
Nov 14 min read


Setting Effective Career Goals for Success
Setting career goals is a crucial step in achieving success in your professional life. Whether you are just starting your career or looking to make a significant change, having clear and actionable goals can guide your path and help you stay focused. In this blog post, we will explore the importance of setting effective career goals, how to create them, and strategies to achieve them. Understanding the Importance of Career Goals Career goals serve as a roadmap for your profes
Nov 14 min read
bottom of page