CNoodle
  • Home
  • Archives
  • Tags
  • About

[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] 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 #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] 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 #array #java #javascript #dynamic programming #greedy

[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

[LeetCode] 55. Jump Game

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. Determine if you
2020-03-04
#leetcode #array #java #javascript #dynamic programming #greedy

[LeetCode] 452. Minimum Number of Arrows to Burst Balloons

There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it’s horizontal, y-coordin
2020-03-04
#leetcode #array #java #greedy #sort

[LeetCode] 225. Implement Stack using Queues

Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty). Implement the MyStack class:void
2020-03-04
#leetcode #java #design #stack
1…3839404142…47

Search

Hexo Fluid