CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 621. Task Scheduler

You are given an array of CPU tasks, each represented by letters A to Z, and a cooling time, n. Each cycle or interval allows the completion of one task. Tasks can be completed in any order, but there
2020-04-26
#leetcode #java #hashmap #greedy #heap

[LeetCode] 18. 4Sum

Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:0 <= a, b, c, d < na, b, c, and d are distinct.nums[a] + nums
2020-04-26
#leetcode #java #javascript #array #two pointer #two sum

[LeetCode] 380. Insert Delete GetRandom O(1)

Design a data structure that supports all following operations in average O(1) time. insert(val): Inserts an item val to the set if not already present.remove(val): Removes an item val from the set if
2020-04-24
#leetcode #java #array #hashmap #math #design #random

[LeetCode] 80. Remove Duplicates from Sorted Array II

Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of the elements should be kept the s
2020-04-22
#leetcode #java #javascript #array #two pointer

[LeetCode] 105. Construct Binary Tree from Preorder and Inorder Traversal

Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree. Exa
2020-04-21
#leetcode #tree #dfs #java #recursion

[LeetCode] 1248. Count Number of Nice Subarrays

Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. Return the number of nice sub-arrays. Example 1:Input: nums = [1,1,2,1,1],
2020-04-21
#leetcode #java #array #hashmap #two pointer #prefix sum

[LeetCode] 36. Valid Sudoku

Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition.Each column must contain
2020-04-20
#leetcode #java #array #hashmap #string

[LeetCode] 378. Kth Smallest Element in a Sorted Matrix

Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix. Note that it is the kth smallest element in the sorted order, not
2020-04-19
#leetcode #java #javascript #matrix #binary search #heap #merge sort

[LeetCode] 733. Flood Fill

You are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image. You are also given three integers sr, sc, and color. Your task is to p
2020-04-17
#leetcode #bfs #dfs #java #flood fill #matrix

[LeetCode] 695. Max Area of Island

You are given an m x n binary matrix grid. An island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded
2020-04-16
#leetcode #bfs #dfs #java #flood fill
1…3031323334…43

Search

Hexo Fluid