CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 543. Diameter of Binary Tree

Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may no
2020-03-18
#leetcode #java #tree #postorder

[LeetCode] 739. Daily Temperatures

Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperatu
2020-03-15
#leetcode #array #java #javascript #stack #monotonic stack

[LeetCode] 6. Zigzag Conversion

The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H NA P L S I I GY
2020-03-14
#leetcode #java #string

[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 #java #javascript #tree #dfs #recursion

[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 #array #java #javascript #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 #java #javascript #tree #dfs #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 #java #javascript #tree #recursion #bst

[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 #array #hashmap #java #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 #array #java #javascript #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 #array #java #javascript #permutation
1…3233343536…41

Search

Hexo Fluid