自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 1123. Lowest Common Ancestor of Deepest Leaves (Medium)

Description:Given a rooted binary tree, return the lowest common ancestor of its deepest leaves.Recall that:The node of a binary tree is a leaf if and only if it has no childrenThe depth of the r...

2019-12-31 09:24:49 138

原创 LeetCode 865. Smallest Subtree with all the Deepest Nodes (Medium)

Description:Given a binary tree rooted at root, the depth of each node is the shortest distance to the root.A node is deepest if it has the largest depth possible among any node in the entire tree....

2019-12-31 09:14:53 143

原创 LeetCode 531. Lonely Pixel I (Medium)

Description:Given a picture consisting of black and white pixels, find the number of black lonely pixels.The picture is represented by a 2D char array consisting of ‘B’ and ‘W’, which means black an...

2019-12-30 16:08:47 168

原创 二分搜索 (Binary Search)

给定一个已经按照从小到大的顺序排好序的整型数组a, 已经一个整型变量target。1. 在数组中查找与target相等的元素/*** Search an element which is equal to the target in the given array.* @param a* @param target* @return If success, return the ind...

2019-12-30 11:48:42 84

原创 LeetCode 167. Two Sum II - Input array is sorted (Easy)

Description:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the ...

2019-12-29 12:32:59 163

原创 LeetCode 442. Find All Duplicates in an Array (Medium)

Description:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it wit...

2019-12-29 05:36:57 101

原创 LeetCode 969. Pancake Sorting (Medium)

Description:Given an array A, we can perform a pancake flip: We choose some positive integer k <= A.length, then reverse the order of the first k elements of A. We want to perform zero or more pa...

2019-12-28 15:27:27 129

原创 Java Array 部分元素排序

Arrays.sort()函数原型Arrays.sort(Array array, int fromIndex, int toIndex, Comparator comparator);public static void main(String[] args) { Integer[] a = new Integer[]{8, 3, 9, 7, 1}; Arrays.sort(...

2019-12-28 14:06:36 1599

原创 Java 日期对象转周几

DateToWeekDaypublic static String DateToWeekDay(Date date) { String[] weekDays = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; Calendar calendar = Calendar.g...

2019-12-28 08:19:38 184

原创 Java 字符串转日期对象 && 日期对象转字符串

StrToDatepublic static Date StrToDate(String str) throws ParseException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = format.parse(str); return dat...

2019-12-28 08:07:07 387

原创 LeetCode 509. Fibonacci Number (Easy)

Description:The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,F(...

2019-12-27 11:47:49 139 1

原创 LeetCode 221. Maximal Square (Medium)

Description:Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.Analysis:Apply 2D dynamic programming to this problem. Initialize a 2D...

2019-12-27 11:43:40 101

原创 LeetCode 561. Array Partition I (Easy)

Description:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as la...

2019-12-26 08:38:31 81

原创 LeetCode 950. Reveal Cards In Increasing Order (Medium)

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 steps r...

2019-12-26 03:32:47 146

原创 Java Array和ArrayList倒置

Array倒置public static void reverseArray(int[] a) { for(int i = 0; i < a.length/2; i++) { int temp = a[i]; a[i] = a[a.length-1-i]; a[a.length-1-i] = temp;...

2019-12-25 13:51:01 376

原创 LeetCode 1266. Minimum Time Visiting All Points (Easy)

Description:On a plane there are n points with integer coordinates points[i] = [xi, yi]. Your task is to find the minimum time in seconds to visit all points.You can move according to the next rules...

2019-12-25 11:40:39 207

原创 LeetCode 513. Find Bottom Left Tree Value(Medium)

Description:Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2:Input: 1 / \ 2 3 / /...

2019-12-24 12:11:59 104

原创 LeetCode 637. Average of Levels in Binary Tree(Easy)

Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1:Input: 3 / \ 9 20 / \ 15 7Output: [3, 14.5, 11]Explanation:...

2019-12-24 08:51:16 131

原创 LeetCode 669. Trim a Binary Search Tree(Easy)

Description:Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tr...

2019-12-24 07:30:36 108

原创 LeetCode 1120. Maximum Average Subtree(Medium)

Description:Given the root of a binary tree, find the maximum average value of any subtree of that tree.(A subtree of a tree is any node of that tree plus all its descendants. The average value of a...

2019-12-23 16:59:51 457

原创 Java判断Stack和Queue是否为空的方法

Stackstack.empty(), 为空返回true,不为空返回false。stack.peek(), 为空返回null,不为空返回栈顶元素。stack.size(), 为空返回0,不为空返回一个大于1的整数。Queuequeue.isEmpty(), 为空返回true,不为空返回false。queue.peek(), 为空返回null,不为空返回栈顶元素。queue.si...

2019-12-23 14:54:50 12069 1

原创 LeetCode 1026. Maximum Difference Between Node and Ancestor(Medium)

Description:Given the root of a binary tree, find the maximum value V for which there exists different nodes A and B where V = |A.val - B.val| and A is an ancestor of B.(A node A is an ancestor of B...

2019-12-23 13:40:00 208

原创 LeetCode 889. Construct Binary Tree from Preorder and Postorder Traversal(Medium)

Return any binary tree that matches the given preorder and postorder traversals.Values in the traversals pre and post are distinct positive integers.Example 1:Input: pre = [1,2,4,5,3,6,7], post = [...

2019-12-23 10:56:55 125

原创 LeetCode 951. Flip Equivalent Binary Trees (Medium)

For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.A binary tree X is flip equivalent to a binary tree Y if and only if we can...

2019-12-22 11:41:02 141

转载 git 清除缓存

git rm -r --cached

2019-12-01 17:13:39 239

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除