Rikam Palkar background image
Author
Rikam Palkar
.NET Full Stack, DSA, C#, React, Blazor, WPF, JavaScript
Mumbai (India)
Recognitions & awards
    • Jun 2020
    • Jun 2021
    • Jun 2022
    • Jun 2023
    • Jun 2024
Badges
Awards & Certifications
  • MCA
    VJTI
About

"Microsoft MVP", Five-time "C# Corner MVP", "Verified author" on Medium "Top voice" on LinkedIn, Author behind 'WPF Simplified' and 'Blazor Simplified'.I'm passionate about making the world a better place by writing scalable, efficient code, I'm skilled at Blazor, WPF, C#, and Data Structures & Algorithms.

Activity

DFS and Maths should never be combined!

#Algorithm
- DFS numbers 1 to 9
- Base condition: If the current number exceeds n, stop recursion.
- Else add the current number to the result list.
Multiply the number by 10 to get to the next level (1 - 10, 10 - 19, 100 - 109).
- For the deeper level:
-- If the next level starting number exceeds n, return.
-- Else, recurse for each number in the range [curr number, curr number, + 9].

Image previewImage preview
Post 12h

Thought of Queue first! Stack approach was easy for edge cases!
#Algorithm
- 26 stacks: one for each letter ('a' to 'z'), to store the indices of those characters.
- Loop input string: Convert the input string into a character array for updates.
- For each character:
-- If it’s a letter, push its index onto the stack corresponding to that letter.
-- If it’s a *, find the smallest letter stack (from 'a' to 'z') that is not empty, pop its top index, and mark that character as '0' - placeholder

Image previewImage preview

It seems like robots and AI are taking over everything these days!

#Algorithm
- Count the frequency of each character in s.
- Use a stack to hold letters as you process s from left to right.
- Track the smallest character from current index to end of s.
- At each step, move the current letter to the stack and update frequency.
- Pop from the stack to the result whenever the top of the stack is ≤ the smallest left character.

Code:
https://lnkd.in/ebraFu_M

#DSA

Image previewImage preview
useRef: The React Hook You’re Sleeping On

useRef: The React Hook You’re Sleeping On

2d 360 0

DSU Was Right There, But Not in My Head

Disjoint Set Algorithm!


#Algorithm

- Convert each char to num and form DSU of both strings

- When Union, always choose the smaller character as the group’s parent to ensure the smallest lexicographical representative.

- Return parent of each node


#Code:
https://github.com/RikamPalkar/DSA-Simplified/blob/main/LeetCode/1061. Lexicographically Smallest Equivalent String.cs


#DSA #Programming #Leetcode


Image previewImage preview
Understanding useState in React

Understanding useState in React

4d 501 0

Who Hid the Candies, deep down the graph?


#Algorithm

- Process boxes in the order you discover them, so BFS hence queue

- If a box is unopened and can be opened (status == 1), open it, collect candies, and mark it as opened.

- Add all the contained boxes and newly unlocked keys to your queue, update their status = 1.

- Repeat until there are no more boxes in the queue.

Image previewImage preview

After a Bunch of Trial and Error!

#Leetcode 135


#Algorithm:

1 - left-to-right pass:

If the next child’s rating is higher, they get 1 more candy than the previous.

2 - Do a right-to-left pass:

If the previous child’s rating is higher, ensure they have at least 1 more candy than the next child.

3. Sum up the candies.


#Code:
https://github.com/RikamPalkar/DSA-Simplified/blob/main/LeetCode/135. Candy.cs


#DSA #Programming

Image previewImage preview
 React Children! Yeah, That’s What They Called

React Children! Yeah, That’s What They Called

1w 509 2

As a kid, Snakes and Ladders was fun, didn’t realize I’d be coding the shortest path for it one day!

#Algorithm:
1. BFS hence Queue, add 1 to begin with.
2. For each move, simulate all 6-sided dice rolls (loop from 1 => 6).
3. Use Helper method to map square numbers to (row, col) on the board.
4. If there’s a snake or ladder (board[row][col] != -1), jump to that destination square.
5. Track visited squares and increment steps at each BFS level.

Image previewImage preview
 Interfaces vs Types in TypeScript

Interfaces vs Types in TypeScript

1w 473 0

Math > Loop

Time, Space: O(1)

#Algorithm

1. Add all numbers from 1 to n

- Use formula: totalSum = n × (n + 1) / 2


2. Add all numbers from 1 to n that are divisible by m

- Count how many: count = n / m

- Then: divisibleSum = m × count × (count + 1) / 2


3. Return nonDivisibleSum - divisibleSum


#Code:
https://github.com/RikamPalkar/DSA-Simplified/blob/main/LeetCode/2894. Divisible and Non-divisible Sums Difference.cs


#Programming #DSA

Image previewImage preview
How to Pass Functions & Params in React + TypeScript

How to Pass Functions & Params in React + TypeScript

1w 448 0
One Cool Trick in React: Memo

One Cool Trick in React: Memo

1w 414 0

Nope, not the frequency array!

#Algorithm
- map to count how many times each word appears.
- Loop through each word:
If its reverse (e.g., "ab" → "ba") is already in the map : res +4
and decrease the count of the reverse word.
- Else, store this word in the dictionary or increase its count.
- Check the dictionary for any word like "cc", "dd" (same letter twice):
If there's at least one such word left, we can use one of them in the middle of the palindrome (adds 2 characters).
- Return the

Image previewImage preview
Let's Start with React Components

Let's Start with React Components

2w 300 0
Create React TS Apps with CRA & Vite

Create React TS Apps with CRA & Vite

2w 396 0

In-place & in pain.


#Algorithm

1. Check 0’s in first row and column

2. If value == 0, flag first row/column

3. Loop and zero marked rows/columns

4. Zero first row/column if flagged


#Code:
https://github.com/RikamPalkar/DSA-Simplified/blob/main/LeetCode/73. Set Matrix Zeroes.cs


#DSA #Programming

Image previewImage preview
Sir, This Is a TypeScript Function

Sir, This Is a TypeScript Function

2w 286 0

Brute force TLE > optimized with diff array!


#Code:
https://github.com/RikamPalkar/DSA-Simplified/blob/main/LeetCode/3355. Zero Array Transformation I.cs


#Algorithm

Create a difference array of len + 1.

For each query [l, r]:

- diff[l] += 1 > we start decrementing from index l

- diff[r + 1] -= 1 > we stop decrementing after index r

Build the prefix sum of diff array, //how many times each index was decremented.

For each index i:

If nums[i] - prefixSumAt[i] > 0, means nums[i] w

Image previewImage preview
Suggested learning
View all