Binary Tree Maximum Path Sum
A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them
Read more →A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them
Read more →Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path.
Read more →You are given the heads of two sorted linked lists list1 and list2.
Read more →Given the root of a binary tree, return all root-to-leaf paths in any order.
Read more →Given an integer n, return the nth digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...].
Read more →Given the root of a binary search tree and the lowest and highest boundaries as low and high
Read more →Given an integer n, return the number of prime numbers that are strictly less than n.
Read more →An ugly number is a positive integer which does not have a prime factor other than 2, 3, and 5.
Read more →Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.
Read more →There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].
Read more →Given an array of strings strs, group the anagrams together. You can return the answer in any order.
Read more →Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
Read more →There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1
Read more →A binary tree is uni-valued if every node in the tree has the same value.
Read more →Given an integer array nums, find a subarray that has the largest product, and return the product.
Read more →Given a binary tree, determine if it is height-balanced.
Read more →You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point
Read more →You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith.
Read more →Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it.
Read more →Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator.
Read more →The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Read more →Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree
Read more →You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee.
Read more →You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking.
Read more →Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were.
Read more →We define the usage of capitals in a word to be right when one of the following cases holds:
Read more →You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order)
Read more →Given a binary tree, find its minimum depth.
Read more →Given the root of a binary tree, determine if it is a valid binary search tree (BST).
Read more →Given the root of a binary tree, return its maximum depth.
Read more →Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.
Read more →You are given an array of integers nums, there is a sliding window of size k.
Read more →A message containing letters from A-Z is being encoded to numbers using the following mapping.
Read more →Given the head of a linked list, rotate the list to the right by k places.
Read more →Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
Read more →Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.
Read more →Given a positive integer num, return true if num is a perfect square or false otherwise.
Read more →The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Read more →Given two binary strings a and b, return their sum as a binary string.
Read more →An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.
Read more →Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators.
Read more →Given two version strings, version1 and version2, compare them. A version string consists of revisions separated by dots '.'. The value of the revision.
Read more →Given a non-empty special binary tree consisting of nodes with the non-negative value.
Read more →Given the root of a binary tree, return the length of the diameter of the tree.
Read more →Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same.
Read more →You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length.
Read more →Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range.
Read more →The count-and-say sequence is a sequence of digit strings defined by the recursive formula
Read more →There is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit)
Read more →A valid IP address consists of exactly four integers separated by single dots. Each integer is between.
Read more →Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
Read more →You are playing the Bulls and Cows game with your friend.
Read more →Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.
Read more →You are given two non-empty linked lists representing two non-negative integers.
Read more →A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED represents a zero or one.
Read more →Given the root of a binary tree, return the leftmost value in the last row of the tree.
Read more →There are n rooms labeled from 0 to n 1 and all the rooms are locked except for room
Read more →There is a robot on an m x n grid. The robot is initially located at the top-left corner.
Read more →Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.
Read more →An n-bit gray code sequence is a sequence of 2n integers where:
Read more →Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false.
Read more →Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).
Read more →Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
Read more →There is an integer array nums sorted in ascending order (with distinct values).
Read more →In this problem, a tree is an undirected graph that is connected and has no cycles.
Read more →Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Read more →You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm.
Read more →Given two strings s and t, determine if they are isomorphic.
Read more →Suppose you have n integers labeled 1 through n. A permutation of those n integers.
Read more →Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing
Read more →Implement pow(x, n), which calculates x raised to the power n (i.e., xn).
Read more →Given a non-negative integer x, return the square root of x rounded down to the nearest intege.
Read more →A magical string s consists of only '1' and '2' and obeys the following rules
Read more →Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c.
Read more →Write a function to find the longest common prefix string amongst an array of strings.
Read more →You are given an array prices where prices[i] is the price of a given stock on the ith day.
Read more →Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums.
Read more →Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order.
Read more →Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level
Read more →Given the head of a linked list, remove the nth node from the end of the list and return its head.
Read more →The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k
Read more →Given the root of a binary tree, return the most frequent subtree sum. If there is a tie, return all the values with the highest frequency in any order.
Read more →Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Read more →LeetCode Problem 1. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
Read more →Given the root of a binary tree, return the inorder traversal of its nodes' values.
Read more →Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it.
Read more →Given an integer n, return the number of trailing zeroes in n.
Read more →Given the root of a binary tree, the depth of each node is the shortest distance to the root.
Read more →Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not pass through.
Read more →Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.
Read more →Given a Tic-Tac-Toe board as a string array board, return true if and only if it is possible to reach
Read more →There is a robot starting at the position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0).
Read more →Given an integer n, return the least number of perfect square numbers that sum to n.
Read more →Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.
Read more →Given an integer column Number, return its corresponding column title as it appears in an Excel sheet.
Read more →Given the root of a binary tree, return the postorder traversal of its nodes' values.
Read more →You are given the root of a binary tree containing digits from 0 to 9 only.
Read more →Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed).
Read more →Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.
Read more →An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated.
Read more →Given an integer n, return true if it is a power of four. Otherwise, return false.
Read more →Given an array of distinct integers candidates and a target integer target.
Read more →Given the roots of two binary trees p and q, write a function to check if they are the same or not.
Read more →Given a string array words, return the maximum value of length(word[i]) * length(word[j])
Read more →Given a triangle array, return the minimum path sum from top to bottom
Read more →Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
Read more →Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum.
Read more →Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Read more →Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
Read more →