- 博客(40)
- 收藏
- 关注
原创 LeetCode之Projection Area of 3D Shapes(Kotlin)
问题:On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes.Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j).Now we v...
2018-12-23 21:38:17
221
原创 LeetCode之Increasing Order Search Tree(Kotlin)
问题:Given a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child.Example 1:Input: [5,3,6,...
2018-12-15 18:09:28
205
原创 LeetCode之Reveal Cards In Increasing Order(Kotlin)
问题:In a deck of cards, every card has a unique integer. You can order the deck in any order you want.Initially, all the cards start face down (unrevealed) in one deck.Now, you do the following st...
2018-12-08 21:21:52
225
原创 LeetCode之DI String Match(Kotlin)
问题:Given a string S that only contains “I” (increase) or “D” (decrease), let N = S.length.Return any permutation A of [0, 1, …, N] such that for all i = 0, …, N-1:If S[i] == “I”, then A[i] < A...
2018-12-01 20:18:40
476
原创 LeetCode之Delete Columns to Make Sorted(Kotlin)
问题:We are given an array A of N lowercase letter strings, all of the same length.Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. ...
2018-11-25 00:45:59
248
原创 LeetCode之Minimum Add to Make Parentheses Valid(Kotlin)
问题:Given a string S of ‘(’ and ‘)’ parentheses, we add the minimum number of parentheses ( ‘(’ or ‘)’, and in any positions ) so that the resulting parentheses string is valid.Formally, a parenthes...
2018-11-18 01:40:19
207
原创 LeetCode之Range Sum of BST(Kotlin)
问题:Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive).The binary search tree is guaranteed to have unique values.Example 1:...
2018-11-14 23:12:17
419
原创 LeetCode之Unique Email Addresses(Kotlin)
问题:Every email consists of a local name and a domain name, separated by the @ sign.For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name.Besides lowercas...
2018-11-04 23:39:25
745
原创 LeetCode之Middle of the Linked List(Kotlin)
问题:Given a non-empty, singly linked list with head node head, return a middle node of linked list.If there are two middle nodes, return the second middle node.Example 1:Input: [1,2,3,4,5]Outpu...
2018-10-27 22:13:28
291
原创 LeetCode之Insert into a Binary Search Tree(Kotlin)
问题:Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the BST after the insertion. It is guaranteed th...
2018-10-20 18:26:26
213
原创 LeetCode之Sort Array By Parity II(Kotlin)
问题:Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, ...
2018-10-14 16:17:33
320
原创 LeetCode之Search in a Binary Search Tree(Kotlin)
问题:Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node’s value equals the given value. Return the subtree rooted with that node. If such...
2018-10-08 19:46:08
132
原创 LeetCode之Partition Labels(Kotlin)
问题:A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representi...
2018-10-06 16:27:32
250
原创 LeetCode之Sort Array By Parity(Kotlin)
问题:Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.You may return any answer array that satisfies this con...
2018-09-22 18:51:03
250
原创 LeetCode之All Paths From Source to Target(Kotlin)
问题: Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in any order. The graph is given as follows: the nodes are 0, 1, …, graph.le...
2018-09-16 13:32:32
169
原创 LeetCode之Peak Index in a Mountain Array(Kotlin)
问题: Let’s call an array A a mountain if the following properties hold: A.length >= 3 There exists some 0 < i < A.length - 1 such that A[0] < A[1] < … A[i-1] < A[i] > A...
2018-09-10 13:52:02
222
原创 LeetCode之Flipping an Image(Kotlin)
问题: Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed...
2018-09-05 14:34:18
147
原创 LeetCode之Unique Morse Code Words(Kotlin)
问题: International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: “a” maps to “.-“, “b” maps to “-…”, “c” maps to “-.-.”, and so on...
2018-08-25 22:14:15
155
原创 LeetCode之Find and Replace Pattern(Kotlin)
问题: You have a list of words and a pattern, and you want to know which words in words matches the pattern. A word matches the pattern if there exists a permutation of letters p so that after ...
2018-08-20 15:12:37
188
原创 LeetCode之Binary Tree Pruning(Kotlin)
问题: We are given the head node root of a binary tree, where additionally every node’s value is either a 0 or a 1. Return the same tree where every subtree (of the given tree) not containing a...
2018-08-18 14:36:24
167
原创 LeetCode之Score After Flipping Matrix(Kotlin)
问题: We have a two dimensional matrix A where each value is 0 or 1. A move consists of choosing any row or column, and toggling each value in that row or column: changing all 0s to 1s, and all...
2018-08-12 22:48:51
181
原创 LeetCode之To Lower Case(Kotlin)
问题: Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.方法: 这个应该不用说了吧,直接看代码。具体实现:class ToLowerCase { fun toLowerCase(str: Str...
2018-08-04 00:34:18
594
原创 LeetCode之Max Increase to Keep City Skyline(Kotlin)
问题: In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the a...
2018-07-28 14:23:00
176
原创 LeetCode之Jewels and Stones(Kotlin)
问题: You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many ...
2018-02-08 17:50:03
380
原创 LeetCode之Prime Number of Set Bits in Binary Representation(Kotlin)
问题: 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
2018-01-28 19:19:33
197
原创 LeetCode之Find Anagram Mappings(Kotlin)
问题: Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. We want to find an index mapping P, from A to B. A mapp
2018-01-20 21:02:17
208
原创 Kotlin语言之内联函数
一、内联函数 内联函数是指用inline关键字修饰的函数。 在类内定义的函数被默认成内联函数。 内联函数从源代码层看,有函数的结构,而在编译后,却不具备函数的性质。 内联函数不是在调用时发生控制转移,而是在编译时将函数体嵌入在每一个调用处。二、Java中的内联函数在java中不能显式地声明函数内联,只能间接通过JVM虚拟机实现。可以通过两种方式向虚拟机提出请求,一种是使用fi
2018-01-17 00:03:37
735
原创 LeetCode之Find Largest Value in Each Tree Row(Kotlin)
问题: You need to find the largest value in each row of a binary tree. Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]方法: 递归实现,遍历所有节点,递归时传递层级,利用map在同一层级保存最大的数值,最后输出m
2018-01-13 15:50:03
165
原创 LeetCode之Sum of Left Leaves(Kotlin)
问题: Find the sum of all left leaves in a given binary tree. 3 / \9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.方法: 递归实现,遍历所
2018-01-07 12:22:53
136
原创 LeetCode之Convert BST to Greater Tree(Kotlin)
问题: Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.方
2017-12-30 15:23:02
163
原创 LeetCode之Construct String from Binary Tree(Kotlin)
问题: You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be represented by empty parenthesis pair “()”
2017-12-26 23:43:41
167
原创 LeetCode之Two Sum IV - Input is a BST(Kotlin)
问题: Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.方法: 与TwoSum的解法差不多,不过需要在其中加入树的遍历,深度优先遍历和广度优先遍
2017-12-23 11:51:16
160
原创 LeetCode之1-bit and 2-bit Characters(Kotlin)
问题: We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11). Now given a string represented by severa
2017-12-22 14:03:16
176
原创 LeetCode之Find Smallest Letter Greater Than Target(Kotlin)
问题: Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list that is larger than the given target. Lett
2017-12-20 23:32:47
351
原创 LeetCode之Find All Numbers Disappeared in an Array(Kotlin)
问题: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this arra
2017-12-19 23:44:42
135
原创 LeetCode之Count Binary Substrings(Kotlin)
问题: Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0’s and 1’s, and all the 0’s and all the 1’s in these substrings are grouped consecutively.
2017-12-16 16:24:33
221
原创 JIT和AOT编译技术
JIT: JIT是Just in time的缩写,也就是即时编译、运行时编译。使用即时编译,能够加速Java程序的执行速度。 .class文件中保存的并不是机器码而只是二进制代码,需要先进行解释,JIT在运行时会把翻译过的机器码保存起来,以备下次使用。 新版本的jvm默认都是采用混合执行模式,半编译(JIT,部门热区代码,经常调用循环的代码)半解释执行。 从理论上来说,采用该JIT技
2017-12-16 13:15:57
3291
原创 如何屏蔽StatusBar和NavigationBar
如何屏蔽StatusBar和NavigationBar代码mLockWindowLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;hideStatusBarAndNavigationBar();mWindowManager.addView(view, mLockWindowLayoutParams.type)priv
2017-04-13 15:31:18
785
原创 Android屏幕适配相关
(1080p,16:9) 1920x1080->xxhdpi->1dp->3px (720p,16:9) 1280x720->xhdpi->1dp=2px (480p,非标准分辨率,略多于4:3) 800x480->hdpi->1.5dp (360p,4:3) 480x320->mdpi->1dp (240p,4:3) 320x240->0.75dp
2017-03-29 18:37:18
232
原创 Window Type的优先级和权限(用于悬浮窗或窗口实现界面)
Type TYPE_PHONE:电话窗口,这是非应用窗口,用于来电的界面,该窗口通常置于所有应用之上,但在状态栏下。 TYPE_SYSTEM_ALERT:系统窗口,例如低电量警告弹窗,在应用窗口之上。 TYPE_TOAST:透明通知,不会拦截触摸事件,可以向下透传。 优先级TYPE_SYSTEM_ALERT > TYPE_PHONE > TYPE_TOAST Androi
2017-03-29 18:22:14
10902
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人