All Posts

Leetcode 498: Diagonal Traverse

You are given an m x n matrix. The task is to return an array that contains all the elements of the matrix in diagonal order, starting from the top-left and moving diagonally towards the bottom-right. The diagonal order alternates between upward and downward diagonals.

Leetcode 537: Complex Number Multiplication

Given two complex numbers represented as strings, multiply them and return the result as a string in the format ‘real+imaginaryi’.

Leetcode 592: Fraction Addition and Subtraction

Given a string expression representing a mathematical expression with fractions involving addition and subtraction, compute the result of the expression. The result should be simplified and returned in the form of a fraction. If the result is an integer, represent it as a fraction with denominator 1.

Leetcode 640: Solve the Equation

Given an equation with a variable ‘x’ and basic arithmetic operations (’+’, ‘-’), find the value of ‘x’. The equation might have a solution, no solution, or infinite solutions. Your task is to return the correct result in the form of a string.

Leetcode 735: Asteroid Collision

You are given an array of integers representing asteroids in a row. Each asteroid has a size and a direction, with positive integers representing asteroids moving right and negative integers representing asteroids moving left. You need to determine the state of the asteroids after all collisions.

Leetcode 844: Backspace String Compare

You are given an integer array arr. A mountain array is an array where the elements first strictly increase to a peak and then strictly decrease after that peak. Your task is to find the length of the longest mountain subarray in the given array. If no such subarray exists, return 0.