CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 948. Bag of Tokens

You start with an initial power of power, an initial score of 0, and a bag of tokens given as an integer array tokens, where each tokens[i] donates the value of tokeni. Your goal is to maximize the to
2020-10-26
#leetcode #two pointer #java #greedy #sort

[LeetCode] 456. 132 Pattern

Given a sequence of n integers a1, a2, …, an, a 132 pattern is a subsequence ai,aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a listof n numbers as input and
2020-10-24
#leetcode #java #treemap #stack #monotonic stack

[LeetCode] 1615. Maximal Network Rank

There is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirectional road between cities ai and bi. The netwo
2020-10-11
#leetcode #java #graph

[LeetCode] 611. Valid Triangle Number

Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.Example 1:Input: nums = [2,2,3,4]Output: 3Ex
2020-10-02
#leetcode #array #two pointer #java #greedy #sort

[LeetCode] 229. Majority Element II

Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Example 1:Input: nums = [3,2,3]Output: [3] Example 2:Input: nums = [1]Output: [1] Example 3:Inpu
2020-09-23
#leetcode #array #java #javascript

[LeetCode] 979. Distribute Coins in Binary Tree

You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree. In one move, we may choose two adjacent nodes
2020-09-22
#leetcode #java #tree #dfs #postorder

[LeetCode] 1291. Sequential Digits

An integer has sequential digits if and only if each digit in the number is one more than the previous digit. Return a sorted list of all the integers in the range [low, high] inclusive that have sequ
2020-09-20
#leetcode #java #bfs #dfs #enumeration

[LeetCode] 421. Maximum XOR of Two Numbers in an Array

Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.Example 1:Input: nums = [3,10,5,25,2,8]Output: 28Explanation: The maximum r
2020-09-17
#leetcode #java #bit manipulation #trie

[LeetCode] 299. Bulls and Cows

You are playing the Bulls and Cows game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the fo
2020-09-11
#leetcode #hashmap #java #string

[LeetCode] 875. Koko Eating Bananas

Koko loves to eat bananas. There are N piles of bananas, the i-th pile has piles[i] bananas. The guards have gone and will come back in H hours. Koko can decide her bananas-per-hour eating speed of
2020-09-09
#leetcode #array #java #binary search #binary search on answer
1…2526272829…44

Search

Hexo Fluid