void
banner
void.imagineer.in
void
@void.imagineer.in
Software Architect | 🩵 crafting products 🛠️
#ProblemSolving Golden ratio can be used to find the nth Fibonacci number!
January 16, 2025 at 4:53 AM
#ProblemSolving Given an array of integers, check if it was originally sorted in non-decreasing order, then rotated. One approach is to compare each element with its previous one and count sorting breaks; for sorted-rotated arrays, it should be 1 (or 0 if all elements are the same).
January 12, 2025 at 1:50 AM
#ProblemSolving For finding the length of the diameter of a binary tree (i.e., length of the longest path between any two nodes), compute longest left path and longest right paths of each node and get maximum of sum of left & right paths recursively.
January 9, 2025 at 3:35 PM
#ProblemSolving Given a sequence of number of steps taken, positive values indicating movement to the right and negative to the left from the starting point boundary, find the number of times it returns to the boundary. One approach to solving this is using prefix sum.
January 6, 2025 at 7:11 AM
#ProblemSolving The middle node of a singly linked list can be found using fast & slow pointers approach
January 4, 2025 at 1:19 AM
This 💯
Happy New Year
January 3, 2025 at 6:22 AM
#ProblemSolving To check if two strings are isomorphic (strings s and t are isomorphic if the characters in s can be replaced to get t), one approach is to create a pattern of indices corresponding to each unique character of a string and compare it with the other string.
January 1, 2025 at 2:24 PM
Happy New Year! 🌍☀️

2025
= (20+25)^2
= (1+2+3+4+5+6+7+8+9)^2
= 1^3+2^3+3^3+4^3+5^3+6^3+7^3+8^3+9^3
= 1+3+5+7+9+11+...+89 [sum of first 45 odd numbers]
= 5^2 * 9^2 [product of two squares]
= 5^2 + 20^2 + 40^2 [sum of 3 squares]
January 1, 2025 at 10:28 AM
#ProblemSolving Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. For this problem, the rejection criteria is strings concatenated in both orders are not the same. A string chunk of length equal to the GCD of the two lengths will be the result.
January 1, 2025 at 5:01 AM
Fun facts about SQLite: avi.im/blag/2024/sq...

Bugs are not always meant to be fixed! Here is an example scenario from SQLite:
December 31, 2024 at 7:24 AM
#ProblemSolving To find if the given number n is a power of 2, that is there exists an integer n such that n == 2^x, we can make use of the property that the bitwise AND with the preceding number is 0 only for all powers of 2 in binary representation.

For example:
15: 01111
16: 10000
AND: 00000
December 29, 2024 at 6:06 AM
"Future maintainers are the ones who have to peel back the layers, trace the indirections, and make sense of how things fit together. They’re the ones paying the real cost of unnecessary abstraction."
fhur.me/posts/2024/t...
December 28, 2024 at 4:19 PM
#ProblemSolving To find the sum of 2 binary numbers, bitwise operation is a good approach. Take XOR, which is the sum for the step, and take AND with a left shift, which is the carry for the step; repeat until the carry becomes zero.
December 28, 2024 at 9:46 AM
#ProgrammingTips To determine if linked list has a cycle in it, Floyd's cycle-finding algorithm can be used (en.wikipedia.org/wiki/Cycle_d...). Implement slow and fast pointers, a cycle is confirmed when they meet.
December 26, 2024 at 7:34 PM
Interesting read: minds.md/zakirullin/c...
December 26, 2024 at 2:24 PM
#ProgrammingTips In an integer list where every element appears twice except for one, XOR helps to find the unique element by canceling out the pairs.
December 25, 2024 at 9:30 PM
An excellent primer to understand Turing machine!
What does it mean for something to be Turing complete?

I answer this question, and more, through a series of fully interactive Turing machine simulations! Play, pause, step forwards and backwards, and even write your own Turing machine programs in my latest blog post.

samwho.dev/turing-machi...
December 25, 2024 at 7:25 PM
Bluesky reminds me of the good old days of Twitter. The cognitive load difference is very apparent. Let's see how it goes! #FirstSkeet 👋
December 25, 2024 at 7:11 PM