Instagram story viewer> @codeinreallife_> Posts
15
followers
0
following
DSA patterns in 3D, 30 sec each 🧊
Placement prep for Indian students + devs
New pattern daily β†’ start with #1 πŸ‘‡
POSTS STORIES REELS TAGGED
Download All
Sliding window technique python leetcode: longest substring without repeating characters, explained in 3D πŸͺŸ DSA Patterns 1/30

Answer for "pwwkew" is 3 β†’ "wke". Grow the window to the right. The moment a character repeats, shrink from the left until the window is clean again.

β€’ seen = set() holds what's inside the window
β€’ while ch in seen: seen.remove(s[left]); left += 1
β€’ seen.add(ch), then best = max(best, right - left + 1)

Gotcha: "pwke" is NOT a substring. p and w aren't next to each other.
TIME O(n): every char enters once and leaves once. SPACE O(k) for the set.

Send this to the friend who still uses nested loops 🀝
SAVE this πŸ“Œ Next up (2/30): Two Pointers.

#datastructuresandalgorithms #codinginterviewprep #leetcodecommunity by @codeinreallife_
1
an hour ago
Download
3 friends. 3 calendars. Only ONE day works for biryani πŸ— β€” Python found it in one line 🀝

Set intersection with & keeps only what's in BOTH (or ALL) sets:
priya & dev & raj β†’ {'Wed'}
Same thing: priya.intersection(dev, raj)

Gotchas:
β€’ It returns a NEW set β€” originals stay untouched
β€’ No overlap? You get set(), not an error
β€’ my_list & my_set β†’ TypeError. Use my_set.intersection(my_list) β€” it takes any iterable

SAVE this πŸ“Œ for the next time you need "what's common" between two lists.
Send it to the friend who always says "I'm free whenever" πŸ˜…

Follow @codeinreallife_ for one real-life coding trick a day.

#codingforbeginners #developerjourney #techcareeradvice #developersindia #codeinreallife by @codeinreallife_
1
17 hours ago
Download
Your calendar has 4 meetings. Two of them overlap? That's really one busy block. That's merge intervals.

Merge intervals = squash every overlapping range into one, so you're left with clean, non-overlapping blocks.
The sort trick: sort by start time. After that, a meeting can only overlap the LAST block you built. Overlaps? Stretch its end: out[-1][1] = max(out[-1][1], e). No overlap? Start a new block.
Sorting costs O(n log n) and the single pass is O(n), with O(n) space for the output. Comparing every pair instead is O(nΒ²).
Dry run: [[1,3],[2,6],[8,10],[15,18]] β†’ 2 ≀ 3 so [1,3] + [2,6] = [1,6] β†’ 8 > 6 new block β†’ 15 > 10 new block β†’ [[1,6],[8,10],[15,18]]

Send this to the friend who double-books every meeting 🀝
SAVE this πŸ“Œ for your next coding interview (or a messy calendar).

Follow @codeinreallife_ for one real-life coding trick a day.

#datastructuresandalgorithms #codinginterviewprep #dsa #programmingconcepts #codingtips by @codeinreallife_
1
21 hours ago
Download
A shop sign nobody notices vs one that pulls you in: same words, different design. Your "Get started" button works the same way πŸ‘‡

Button glow-up in 5 CSS lines:
1️⃣ padding + border-radius β†’ room to breathe, soft corners, looks tappable
2️⃣ background + color + font-weight β†’ contrast, the eye lands here first
3️⃣ box-shadow β†’ a soft brand glow lifts it off the page
4️⃣ :hover { transform: translateY(-2px) } β†’ it feels pressable
5️⃣ :focus-visible + outline-offset β†’ keyboard users see exactly where they are

⚠️ Gotcha: never remove outline (outline: none) without a :focus-visible replacement. Tab users get lost.

Every button you see is real HTML/CSS rendered in Chrome.

Send this to your frontend buddy 🀝
SAVE this πŸ“Œ for your next landing page.
Follow @codeinreallife_ for one real-life coding trick a day.

#css #webdevelopment #frontenddeveloper #uidesign #learntocode by @codeinreallife_
1
2 days ago
Download
Priya: "who finished the chai AGAIN?" 😀 Dev: "not me. I had like… one cup" β€” so she let Python decide.

Counter(chai) tallies every item in a list.
cups.most_common(1) β†’ [('Dev', 3)] β€” top item + its count.

Gotcha: a missing key returns 0, not KeyError β†’ cups["Mom"] == 0.
Ties keep first-seen order, and most_common() with no number returns everything, sorted.

Rule: need a tally? Don't write a loop with a dict β€” Counter it.

SAVE this πŸ“Œ for the next time you count votes, words or chores.
Send it to the roommate who "only had one cup".

Follow @codeinreallife_ for one real-life coding trick a day.

#pythonprogramming #pythoncoding #pythonfordevelopers #learntocode #techskills by @codeinreallife_
1
2 days ago
Download
Your phone's recent-apps tray only holds 3. Open one and it jumps to newest. Open a 4th and the oldest one gets closed. That's an LRU cache.

LRU = Least Recently Used: when the cache is full, drop whatever you haven't touched the longest.
The OrderedDict trick: get β†’ move_to_end(k). put β†’ move_to_end(k), then popitem(last=False) when you go over capacity.
Every get and put is O(1). Keeping the order in a plain list means remove() / pop(0), which costs O(n) on every touch.
Dry run with cap=3: put 1A 2B 3C Β· get 1 Β· put 4D β†’ evicts 2 β†’ get(2) = -1, get(3) = 'C'

Send this to your interview buddy 🀝
SAVE this πŸ“Œ for your next system-design / interview question.

Follow @codeinreallife_ for one real-life coding trick a day.

#pythonprogramming #pythoncoding #pythonfordevelopers #pythonprojects #learntocode by @codeinreallife_
1
2 days ago
Download
Priya: "we pair perfectly… right?"
Dev: "exactly. like zip()"

us = ["Priya", "Dev"]
love = ["chai", "python"]
print(list(zip(us, love)))
# β†’ [('Priya', 'chai'), ('Dev', 'python')]

Gotcha: zip stops at the shortest list.

SAVE this for your next pair-programming date πŸ“Œ
Follow for one real-life coding trick a day

#pythonprogramming #pythoncoding #codingtips #learntocode #codeinreallife by @codeinreallife_
1
3 days ago
Download
Picture a wedding photo line: everyone looks to their right for the first person taller than them. That's the monotonic stack.

Dry run: nums = [2,1,5,3,6,4]
Shorter people wait on a stack. When someone taller steps in, pop everyone shorter, because they just found their answer.
5 arrives β†’ pops 1 and 2 (ans = 5, 5)
6 arrives β†’ pops 3 and 5 (ans = 6, 6)
6 and 4 are still waiting at the end β†’ -1
Next greater β†’ [5,5,6,6,-1,-1]
Brute force makes everyone scan right again (O(nΒ²) worst case). The stack does it in one pass.
Cyan = scan/push. Amber = popped (found taller). Emerald = answer. Muted = -1.

TIME O(n) Β· SPACE O(n)
Rule: Shorter? Wait on the stack. Taller arrives? Pop & answer. Still waiting at the end? -1.

SAVE this πŸ“Œ for your next stack interview question. Send it to the friend who still nests two loops for "next greater".

Follow @codeinreallife_ for one real-life coding trick a day.

#datastructuresandalgorithms #codinginterviewprep #dsa #programmingconcepts #codingtips by @codeinreallife_
1
3 days ago
Download
Kadane's is a stock-trading streak: if your running total goes negative, drop the baggage and start fresh.

Dry run: nums = [-2,1,-3,4,-1,2,1,-5,4]
cur = max(x, cur + x) Β· best = max(best, cur)
cur after each day β†’ [-2,1,-2,4,3,5,6,1,5]
Resets (start fresh) at index 1 and index 3: cur was negative, so we dropped it
Best streak β†’ nums[3..6] = [4,-1,2,1] = 6
Brute force β†’ checks all 45 subarrays (O(nΒ²)). Kadane β†’ one pass.
Cyan = scan/extend. Amber = reset. Emerald = best window. Sunk cuboids = negatives.

TIME O(n) Β· SPACE O(1)
Rule: Running sum went negative? Drop it, start fresh at x. Track best as you go.

SAVE this πŸ“Œ for your next max-subarray interview. Send it to the friend still writing two nested loops.

Follow @codeinreallife_ for one real-life coding trick a day.

#datastructuresandalgorithms #codinginterviewprep #dsa #programmingconcepts #codingtips by @codeinreallife_
1
3 days ago
Download
A prefix sum is a car odometer: to know how far you drove between two towns, subtract two readings β€” never re-drive the road.

Dry run: nums = [3,1,4,1,5,9,2]
Build once: P = [0,3,4,8,9,14,23,25] (P[i+1] = P[i] + nums[i])
Query range_sum(2, 5):
Brute force β†’ 4 + 1 + 5 + 9 = 19 (re-adds the range every query)
Prefix sum β†’ P[6] βˆ’ P[2] = 23 βˆ’ 4 = 19 (one subtraction)
Cyan = scan/build. Amber = P[l] reading. Emerald = P[r+1] / answer.

TIME O(n) build Β· O(1) per query Β· SPACE O(n)
Rule: Many range sums? Build P once β€” answer = P[r+1] βˆ’ P[l]. Never re-sum the range.

SAVE this for your next range-sum interview. Send it to the friend still looping over every subarray.

Follow @codeinreallife_ for code that actually shows up in real life.

#datastructuresandalgorithms #codinginterviewprep #dsa #programmingconcepts #codingtips by @codeinreallife_
2
4 days ago
Download
Two pointers are two people walking toward each other on a sorted hallway: too big, right steps back; too small, left steps forward.

Dry run: nums = [1,2,4,7,11,15], target = 15
L=0, R=5 β†’ 1 + 15 = 16 > 15 β†’ R steps back
L=0, R=4 β†’ 1 + 11 = 12 < 15 β†’ L steps forward
L=1, R=4 β†’ 2 + 11 = 13 < 15 β†’ L steps forward
L=2, R=4 β†’ 4 + 11 = 15 β†’ FOUND (4, 11)
Cyan = left pointer L. Amber = right pointer R. Emerald = found match.

TIME O(n) Β· SPACE O(1)
Rule: On a sorted array, move the end that fixes the sum β€” never scan every pair.

SAVE this for your next pair-sum interview. Send it to the friend still writing nested loops.

Follow @codeinreallife_ for code that actually shows up in real life.

#datastructuresandalgorithms #codinginterviewprep #dsa #programmingconcepts #codingtips by @codeinreallife_
1
4 days ago
Download
Sliding window is a moving train window: add what enters, remove what leaves.

Dry run: nums = [2,1,5,1,3,2], k = 3 β†’ windows 8, 7, 9, 6 β†’ best = 9 ([5,1,3]).
Amber = element entering. Cyan = element leaving / compare. Emerald = new best.

TIME O(n) Β· SPACE O(1)
Rule: Don't re-sum the window β€” add the new, drop the old.

SAVE this for your next sliding-window interview. Send it to your interview buddy.

Follow @codeinreallife_ for code that actually shows up in real life.

#datastructuresandalgorithms #codinginterviewprep #leetcodecommunity #algorithmdesign #codingtips by @codeinreallife_
1
4 days ago
Download
×

Download all media on this page

Photos Videos
back to up