freeCookie


freeCookie_🍪

Leetcode - Trie Hard

LC212, LC336, LC425, LC472

前缀树的hard题,一般前缀树与DFS BFS搜索或者其他数据结构结合起来搞一天之类。 LC. 212 Word Search II Given a 2D board and a list of words from the dictionary, find all words in th...

LC444. Sequence Reconstruction

Sequence Reconstruction

LC444. Sequence Reconstruction 给定int[ ] org和int[[ ]] seqs,求根据seqs的顺序能否唯一构成org。典型的拓扑排序问题,建立邻接表和入度表,利用队列进行排序,唯一的含义就是每次更新队列只有一个元素的入度为0并且所有的元素都进行过排序的过...

LC300. Longest Increasing Subsequence

not necessarily continuous

Question Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18],...

Leetcode - Binary Search Tree

LC220, LC315, LC327, LC352

LC220. Duplicate III Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference bet...

Leetcode - Single Number I/II/III

Single Number I/II/III

Single Number I All appear twice except for one, find that one. Naive O(nlgn) 26%?: public class Solution { public int singleNumber(int[] nu...

Leetcode - Stock Problems

Best Time to Buy and Sell Stock

LC121. Best Time to Buy and Sell Stock One transaction. O(n). Find min buying day and max selling day. public class Solution { public int ma...

Leetcode - Segment Tree/ Binary Index Tree

LC315, LC308, LC307, LC218

LC 315 Count of Smaller Numbers After Self Given an array nums[i], count the number of integers to the right of nums[i] and put them out in a list...

Leetcode - Rotated Array

Find or Search in rotated array

LC33. Search in Rotated Sorted Array You are given a target value to search. If found in the array return its index, otherwise return -1. No dupli...