CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 277. Find the Celebrity

Suppose you are at a party with n people labeled from 0 to n - 1 and among them, there may exist one celebrity. The definition of a celebrity is that all the other n - 1 people know the celebrity, but
2020-05-11
#leetcode #java #graph

[LeetCode] 997. Find the Town Judge

In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then:The town judge trusts nobody.Everybody (except f
2020-05-11
#leetcode #hashmap #java #graph

[LeetCode] 463. Island Perimeter

You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonall
2020-05-08
#leetcode #hashmap #java #javascript

[LeetCode] 1249. Minimum Remove to Make Valid Parentheses

Given a string s of ‘(‘ , ‘)’ and lowercase English characters. Your task is to remove the minimum number of parentheses ( ‘(‘ or ‘)’, in any positions ) so that the resulting parentheses string is va
2020-05-08
#leetcode #java #string #stack

[LeetCode] 84. Largest Rectangle in Histogram

Given an array of integers heights representing the histogram’s bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram. Example 1:Input: heights =
2020-05-08
#leetcode #array #java #javascript #stack #monotonic stack

[LeetCode] 993. Cousins in Binary Tree

Given the root of a binary tree with unique values and the values of two different nodes of the tree x and y, return true if the nodes corresponding to the values x and y in the tree are cousins, or f
2020-05-08
#leetcode #java #tree #bfs #dfs

[LeetCode] 443. String Compression

Given an array of characters chars, compress it using the following algorithm:Begin with an empty string s. For each group of consecutive repeating characters in chars:If the group’s length is 1, appe
2020-05-08
#leetcode #two pointer #java #string #simulation

[LeetCode] 286. Walls and Gates

You are given an m x n grid rooms initialized with these three possible values. -1 A wall or an obstacle.0 A gate.INF Infinity means an empty room. We use the value 231 - 1 = 2147483647 to repres
2020-05-02
#leetcode #array #java #bfs #flood fill

[LeetCode] 130. Surrounded Regions

You are given an m x n matrix board containing letters ‘X’ and ‘O’, capture regions that are surrounded: Connect: A cell is connected to adjacent cells horizontally or vertically.Region: To form a reg
2020-05-02
#leetcode #array #java #bfs #dfs #matrix

[LeetCode] 1095. Find in Mountain Array

(This problem is an interactive problem.) You may recall that an array arr is a mountain array if and only if: arr.length >= 3There exists some i with 0 < i < arr.length - 1 such that:ar
2020-04-29
#leetcode #array #java #binary search
1…3031323334…44

Search

Hexo Fluid