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 →There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean.
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 →The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.
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 →You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.
Read more →There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1
Read more →Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.
Read more →Given a string s, sort it in decreasing order based on the frequency of the characters.
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 →A k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events.)
Read more →You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point
Read more →Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n.
Read more →Given a string s, find the length of the longest substring without duplicate characters.
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 →Given the root of a binary tree, return the maximum width of the given tree.
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 a license key represented as a string s that consists of only alphanumeric characters and dashes
Read more →Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.
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 an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where:
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 a string s and an array of strings words. All the strings of words are of the same length.
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 an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or false
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 head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
Read more →Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.
Read more →Given two strings s and t of lengths m and n respectively, return the minimum window substring
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 →Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray).
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 a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent
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 →There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings.
Read more →Given a non-empty special binary tree consisting of nodes with the non-negative value.
Read more →Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.
Read more →Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target 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 →Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties
Read more →The count-and-say sequence is a sequence of digit strings defined by the recursive formula
Read more →Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list.
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 →Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.
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 →There are some spherical balloons taped onto a flat wall that represents the XY-plane
Read more →Given a string licensePlate and an array of strings words, find the shortest completing word in words.
Read more →You are given an integer array cost where cost[i] is the cost of ith step on a staircase.
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 →You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking.
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 →Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending 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 →Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses.
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 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 →Let's play the minesweeper game (Wikipedia, online game)!
Read more →Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head.
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 →You are given an integer array nums consisting of n elements, and an integer k
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 →Given the head of a singly linked list and an integer k, split the linked list into k consecutive linked list parts.
Read more →Given the head of a sorted linked list
Read more →Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.
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 →A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.
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 two strings s and t, return true if they are equal when both are typed into empty text editors.
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 →The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.
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 two strings s and goal, return true if you can swap two letters in s so the result is equal to goal
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 string num that contains only digits and an integer target, return all possibilities to insert the binary operators
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 array nums where every element appears three times except for one, which appears exactly once
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 →You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index.
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 an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).
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 the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.
Read more →Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.
Read more →A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance
Read more →One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record.
Read more →Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.
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 →You are given the head of a linked list containing unique integer values and an integer array nums that is a subset
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 →