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

Check if the linked list is a palindrome.

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

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:

A trivial answer for leetcode #62

And this approach works fine in Python:

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:

linked list when length is odd

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.

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

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…

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

Just as an illustration.


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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store