# Destructive algorithms when solving whiteboarding task

There was a discussion in comments on Stackoverflow in Russian about detecting palindrome.

I give such an example for checking the linked list for palindrome (it’s leetcode #234 Palindrome Linked List):

# Avoid integer overflow when calculating factorials. Based on leetcode #62 Unique Paths

Using math for solving many programming problems is the fastest way.
For example, you can solve leetcode #62 Unique Paths mathematically. A result is number of n — 1 combinations from m — 1 + n — 1:

# Digging around leetcode #876 Middle of the Linked List

Today when I repeated the solution for leetcode #876 Middle of the Linked List, I thought suddenly. What if we need to return the first middle element, not the second?

Let me remind you. The list can contain an odd number of elements:

# ATM analogy for leetcode #104 Maximum Depth of Binary Tree

I’ve found an ATM analogy answering what recursion is in this video.

This analogy may help you to solve leetcode #104 Maximum Depth of Binary Tree. All you need is to imagine that you have multiple ATMs and need to choose a max path:

As for me, it’s a simple analogy helping to remember the recursive approach for solving this problem.

# Leetcode #67 and avoiding edge cases

I often see a typical solution for leetcode #67 Add Binary:

# Leetcode #0119. How create formula for O(N) solution

Two days ago I tried to solve again leetcode problem 0119 Pascal’s triangle using the math approach. It is the fastest approach to calculate row in Pascal’s triangle, but… I can’t understand how it works and how to remember the formulas.

So, let’s begin from the base.

In leetcode problem…

# The easiest way to traverse binary tree postorder iteratively. What’s the catch?

Traverse binary tree iteratively is hard to remember, especially for postorder.

Just as an illustration.

Preorder:

# Why using one dictionary for leetcode #205 is a bad idea?

I often see that candidates use one dictionary when solving leetcode problem #205 ‘Isomorphic Strings’.

There are a lot of submissions in leetcode discussions, they are something like this: ## Andrei Kruglov

Software Engineer