freeCookie


freeCookie_🍪

LC302. Smallest Rectangle Enclosing Black Pixels

LC302. Smallest Rectangle Enclosing Black Pixels An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The bl...

LC214. Shortest Palindrome

Convert string to shortest palindrome.

LC214. Shortest Palindrome Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return th...

KMP ?_?

KMP 个人理解

KMP (?_?) 今天做LC214. Shorest Palindrome, 第一次接触KMP算法。借此机会学习一下KMP算法。👇 然后发现不用KMP也能做 KMP: 图灵社区 Wiki GeeksforGeeks KMP算法是两个字符串匹配的算法,例如,在S(S...

Leetcode Read N Characters Given Read4 I/II

LC157, LC158

LC157. Read N Characters Given Read4 The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number...

LC23. Merge k Sorted Lists

Merge k Sorted Lists

LC23. Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. 归并排序一大堆排序的链表。 Recursion Solution 先分成2个两个的再进行merge直...

LC224. Basic Calculator

+, -, (, )

LC224. Basic Calculator Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing...

LC10. Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.

Regular Expression Matching '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the en...

Leetcode - Trie Medium

LC421, LC208, LC211

Trie, 前缀树。个人习惯每个Node具有如下结构: class Node{ String word; Node[] next; public Node(){ word = null; next = new Node[26]; } } 前缀树对于Stri...