2.2k words 2 mins.

787 · The Maze - LintCode # Description There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up , down , left or right , but it won't stop rolling until hitting a wall . When the ball stops, it could choose the next direction. Given the...
2.4k words 2 mins.

1080 · Max Area of Island - LintCode # Description Given a non-empty 2D array grid of 0's and 1's, 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 by water. Find the maximum...
1.4k words 1 mins.

433 · Number of Islands - LintCode # Description Given a boolean 2D matrix, 0 is represented as the sea, 1 is represented as the island. If two 1 is adjacent, we consider them in the same island. We only consider up/down/left/right adjacent. Find the number of islands. # Solution public class...
1.6k words 1 mins.

40 · Implement Queue by Two Stacks - LintCode # Description As the title described, you should only use two stacks to implement a queue's actions. The queue should support push(element) , pop() and top() where pop is pop the first(a.k.a front) element in the queue. Both pop and top methods...
967 words 1 mins.

209 · First Unique Character in a String - LintCode # Description Given a string and find the first unique character in a given string. You can assume that there is at least one unique character in the string. # Example Example 1: Input: "abaccdeff" Output:...
1.4k words 1 mins.

1046 · Prime Number of Set Bits in Binary Representation - LintCode # Description Given two integers L and R , find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation. (Recall that the number of set bits an integer has is the number...
1.5k words 1 mins.

167 · Add Two Numbers - LintCode # Description You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum...
1.1k words 1 mins.

medium question regular expression Write a class called MyRegex which will contain a string pattern. You need to write a regular expression and assign it to the pattern such that it can be used to validate an IP address. Use the following definition of an IP address: IP address is a string in the...
11k words 10 mins.

以下筆記全來自韓順平老師的影片:【韩顺平讲 Java】Java 正则表达式专题 - 正则 正则表达式 元字符 限定符 Pattern Matcher 分组 捕获 反向引用等_哔哩哔哩_bilibili 最愛韓順平老師,向他比心! # 正則表達式簡介 簡介:正則表達式是對字符串報行模式匹配的技術。 英文:regular expression ;簡稱 Regex /regexp 用途:Java 裡的正則表達式可以有效處理文本。 不只有 java,像 javascript, php 等都支持正則表達式。 假設我要從一個中文文本裡取出英文單詞,用傳統的方法的話,就是先看看當前 character...
1.2k words 1 mins.

[[Lintcode problems]] URL : 66 · Binary Tree Preorder Traversal - LintCode # Description Given a binary tree, return the preorder traversal of its nodes' values. Example 1: Input: binary tree = {1,2,3} Output: [1,2,3] 主要的考點是不用 recursion 寫出 preorder 用 stack + while 的方法寫 #...