All Posts

Leetcode 53: Maximum Subarray

Given an integer array nums, find the contiguous subarray (containing at least one number) that has the largest sum and return its sum.

Leetcode 105: Construct Binary Tree from Preorder and Inorder Traversal

Given two integer arrays, preorder and inorder, representing the preorder and inorder traversals of a binary tree, your task is to reconstruct and return the binary tree. The values in the arrays are unique, and the preorder traversal provides the sequence in which nodes are visited before their children, while the inorder traversal provides the order in which nodes are visited between their children.

Leetcode 109: Convert Sorted List to Binary Search Tree

Given the head of a singly linked list where elements are sorted in ascending order, convert it into a height-balanced binary search tree. A height-balanced binary search tree is one where the depth of the two subtrees of every node never differs by more than 1.

Leetcode 169: Majority Element

Given an array nums of size n, return the majority element. The majority element is the element that appears more than n // 2 times. You may assume that the majority element always exists in the array.

Leetcode 190: Reverse Bits

Given a 32-bit unsigned integer, reverse its bits and return the result as an unsigned integer.

Leetcode 191: Number of 1 Bits

Given a positive integer n, return the number of set bits (1s) in its binary representation, also known as the Hamming weight.