CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 572. Subtree of Another Tree

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 otherwise. A subtree of a binary tree tree
2020-03-12
#leetcode #tree #dfs #java #javascript #recursion

[LeetCode] 450. Delete Node in a BST

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. Basically, the deletion can be divided into
2020-03-12
#leetcode #tree #java #recursion #bst

[LeetCode] 1122. Relative Sort Array

Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as
2020-03-11
#leetcode #java #javascript #array #counting sort

[LeetCode] 236. Lowest Common Ancestor of a Binary Tree

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p a
2020-03-10
#leetcode #tree #dfs #java #javascript #recursion

[LeetCode] 235. Lowest Common Ancestor of a Binary Search Tree

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between t
2020-03-10
#leetcode #tree #java #javascript #recursion #bst

[LeetCode] 295. Find Median from Data Stream

The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values. For example, for arr = [
2020-03-10
#leetcode #java #design #heap

[LeetCode] 347. Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2] Example 2
2020-03-08
#leetcode #java #array #hashmap #bucket sort #heap

[LeetCode] 41. First Missing Positive

Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums. You must implement an algorithm that runs in O(n) time and uses O(1) auxiliary space. Example 1:
2020-03-06
#leetcode #java #javascript #array #bucket sort

[LeetCode] 31. Next Permutation

A permutation of an array of integers is an arrangement of its members into a sequence or linear order. For example, for arr = [1,2,3], the following are all the permutations of arr: [1,2,3], [1,
2020-03-05
#leetcode #java #javascript #array #permutation

[LeetCode] 45. Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to r
2020-03-05
#leetcode #java #javascript #array #dynamic programming #greedy
1…3435363738…43

Search

Hexo Fluid