All Posts

Leetcode 226: Invert Binary Tree

Given the root of a binary tree, invert the tree by swapping the left and right subtrees of every node, and return its root.

Leetcode 228: Summary Ranges

You are given a sorted array of unique integers. Your task is to group consecutive numbers into ranges and return a sorted list of these ranges. A range [a,b] includes all integers from a to b (inclusive). Each range should be represented as ‘a->b’ if a != b or ‘a’ if a == b.

Leetcode 231: Power of Two

Given an integer n, determine if it is a power of two. An integer n is considered a power of two if there exists an integer x such that n == 2^x.

Leetcode 232: Implement Queue using Stacks

Design and implement a queue using only two stacks. The queue should support the basic operations of a normal queue: enqueue, dequeue, peek, and checking if the queue is empty.

Leetcode 242: Valid Anagram

You are given two strings, s and t. Determine if t is an anagram of s. Two strings are considered anagrams if they contain the exact same characters, but possibly in a different order.

Leetcode 258: Add Digits

Given a non-negative integer num, repeatedly add all of its digits until the result has only one digit, and return it.