All Posts

Leetcode 20: Valid Parentheses

You are given a string containing characters representing various types of brackets: ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’. Your task is to determine if the input string is valid. A string is considered valid if:

  1. Open brackets must be closed by the same type of brackets.
  2. Open brackets must be closed in the correct order.
  3. Every close bracket has a corresponding open bracket of the same type.

Leetcode 71: Simplify Path

Given an absolute path for a Unix-style file system, simplify the path by following Unix file system rules. Handle ‘.’ and ‘..’ as current and parent directories, and multiple slashes as a single slash. Return the simplified canonical path.

Leetcode 94: Binary Tree Inorder Traversal

Given the root of a binary tree, return the values of its nodes as they appear in an inorder traversal. Inorder traversal visits nodes in the left subtree, the root, and then the right subtree.

Leetcode 114: Flatten Binary Tree to Linked List

Given the root of a binary tree, flatten the tree into a ’linked list’ where each node’s right pointer points to the next node in pre-order traversal, and the left pointer of all nodes is null. The ’linked list’ should maintain the same order as a pre-order traversal of the binary tree.

Leetcode 143: Reorder List

You are given the head of a singly linked list. The goal is to reorder the list such that the nodes are arranged as follows: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → …, without modifying the values of the nodes. Only the structure of the list can be changed.

Leetcode 144: Binary Tree Preorder Traversal

You are given the root of a binary tree. The task is to return the preorder traversal of the tree. Preorder traversal means visiting the root node first, followed by the left subtree, and then the right subtree.