自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 [LeetCode Solution 98]: Validate Binary Search Tree

[LeetCode Solution 98] Validate Binary Search Tree

2017-09-04 00:03:57 255

原创 [LeetCode Solution 54] Spiral Matrix

Question:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7

2017-09-03 02:44:55 235

原创 [LeetCode 145] Binary Tree Postorder Traversal

Question:Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1]Approach #1 Recursive [Accepted]De

2017-08-28 08:09:04 453

原创 [LeetCode 144] Binary Tree Preorder Traversal

Binary Tree Preorder Traversal

2017-08-27 12:00:06 210

原创 LeetCode@String_412_Fizz_Buzz

Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. Fo

2017-07-02 11:59:47 166

原创 LeetCode@Array_605_Can_Place_Flowers

Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.Gi

2017-07-01 12:01:23 140

原创 LeetCode@Dynamic_70_Climbing_Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?java:public class

2017-07-01 11:59:11 142

原创 leetcode@Tree_563_Binary_Tree_Tilt

Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtre

2017-07-01 11:57:00 149

原创 LeetCode@111_Minimum_Depth_of_Binary_Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.java:/** * Definition f

2017-06-29 11:28:18 150

原创 LeetCode@513_Find_Bottom_Left_Tree_Value

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

2017-06-29 11:25:52 166

原创 LeetCode@107_Binary_Tree_Level_Order_Traversal_II

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15,

2017-06-28 11:27:14 189

原创 LeetCode@102_Binary_Tree_Level_Order_Traversal

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20

2017-06-28 11:24:55 163

原创 LeetCode@543_Diameter_of_Binary_Tree

Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may n

2017-06-28 11:22:42 143

原创 LeetCode@HashMap_404_Sum_of_Left_Leaves

Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.

2017-06-27 04:45:15 154

原创 LeetCode@Tree_404_Sum_of_Left_Leaves

404. Sum of Left LeavesDescriptionHintsSubmissionsSolutionsDiscuss Editorial SolutionPick OneFind the sum of all left leaves in a given binary tree.

2017-06-26 23:10:12 182

原创 LeetCode@HashMap_389_Find_the_Difference

389. Find the DifferenceDescriptionHintsSubmissionsSolutionsDiscuss Editorial SolutionPick OneGiven two strings s and t which consist of only lowercas

2017-06-26 10:43:51 185

原创 LeetCode@Tree_226_Invert_Binary_Tree

problem:invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1java:/** * Definition for a binary tree node. * public

2017-06-25 07:49:25 135

原创 LeetCode@Tree_112_Path_Sum

Problem:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary

2017-06-25 07:45:54 152

原创 LeetCode@Tree_606_Construct_String_from_Binary_Tree

Problem:ou 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-06-24 12:13:44 162

原创 LeetCode@Bit_461_Hamming_Distance

Problem:The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.

2017-06-23 12:03:13 164

原创 LeetCode@Tree_617_Merge_Two_Binary_Trees

Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tr

2017-06-22 12:24:48 134

原创 LeetCode@DFS_257_Binary_Tree_Paths

Problem:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Java:/** * Definition for a binary tree node. * public class TreeNode { * int val;

2017-06-20 20:01:40 176

原创 LeetCode@DFS_257_Binary_Tree_Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]jav

2017-06-20 11:43:56 148

原创 LeetCode@Stack_20_Valid_Parentheses

20. Valid ParenthesesDescriptionHintsSubmissionsSolutionsTotal Accepted: 202863Total Submissions: 612017Difficulty: EasyContributor: LeetCodeGiven a string co

2017-06-19 11:49:08 174

原创 LeetCode@Tree_110_Balanced_Binary_Tree

110. Balanced Binary TreeDescriptionHintsSubmissionsSolutionsTotal Accepted: 172600Total Submissions: 465133Difficulty: EasyContributor: LeetCodeGiven a binar

2017-06-18 18:58:25 141

原创 LeetCode@Tree_100_Max_Depth_B_Tree

104. Maximum Depth of Binary TreeDescriptionHintsSubmissionsSolutionsTotal Accepted: 241399Total Submissions: 462901Difficulty: EasyContributor: LeetCodeGiven

2017-06-18 10:43:42 216

原创 LeetCode@Tree_101_Symmetric Tree

Problem:Java:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */pu

2017-06-17 11:21:09 133

原创 LeetCode@Tree_572_Subtree_of_Another_Tree

Problem:JAVA:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */publ

2017-06-16 01:43:05 146

原创 LeetCode@Tree_100_Same_Tree

Problem:JAVA:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */publ

2017-06-16 01:40:29 152

原创 从数据库中取出数据

package com.jTable;import java.util.Vector;import javax.swing.*;import java.util.*;import java.sql.*;import java.awt.*;public class Demo1 extends JFrame{ JTable jt = null; JScrollPane jsp

2017-06-15 01:09:30 2260

原创 JAVA && MySQL

package com.ConnectionSQL;import java.sql.*;public class Demo1{ Connection ct = null; PreparedStatement ps= null; ResultSet rs = null; static final String JDBC_Driver = "com.mysql.jdbc.Driver

2017-06-13 05:16:43 178

原创 LeetCode@HashTable_575_DistributeCandies

Problem:JAVA:import java.util.*;public class Solution { public int distributeCandies(int[] candies) { Set kinds = new HashSet<>(); int total = candies.length; for (int i = 0;

2017-06-09 23:39:09 139

原创 LeetCode@Math_507_Perfect_Number

Problem:JAVApublic class Solution { public Boolean checkPerfectNumber(int num) { if (num < 2) return false; int sum = 1; for (int x = 2; x * x <= num; x++) { if (num % x

2017-06-09 12:10:10 203

原创 LeetCode@Array_35_Search_Insert_Position

Problem:javapublic class Solution {public int searchInsert(int[] nums, int target) { int index = 0; for(int i =0;i<nums.length;i++) { if(nums[i] == target) { index = i; b

2017-06-08 12:40:08 152

原创 LeetCode@Array_136_Single_Number

Problem:Java public class Solution {public int singleNumber(int[] nums) { HashMap map = new HashMap<>(); Integer key = null; for (int i = 0; i < nums.length; i++) { if (!map.contain

2017-06-07 12:49:44 197

原创 LeetCode@Array_268_Missing_Number

Problem:Java:public class Solution { public int missingNumber(int[] nums) { HashMap map = new HashMap<>(); for(int i = 0;i< nums.length;i++) { map.put(nums[i], i); } for(

2017-06-06 10:54:49 133

原创 LeetCode@Array_169_Majority_Element

Problem:javapublic class Solution { int majorityElement(vector &num) { int vote = num[0]; int count = 1; int size = num.size(); //vote from the second number for( int i = 1;

2017-06-05 11:03:23 145

原创 LeetCode@Array_215_Kth_Largest_Element_in_an_Array

Problem:Algorithm算法导论:Order StatisticJava:public class Solution { public int findKthLargest(int[] a, int k) { int n = a.length; int p = quickSelect(a, 0, n - 1, n - k + 1);

2017-06-04 11:22:54 150

原创 LeetCode@Array_414_Third_Maximum_Number

Problem:Algorithm:策略:每加入一个元素,判断这个元素1st_max? 2nd_max? 3rd_max; 判断方式如代码所示注意⚠️:return 判断是否是long最小值用于返回没有3rd_max的情况,此时返回1st_max;Java :public class Solution { public int thirdMax(int

2017-06-03 11:40:12 172

原创 LeetCode@LinkedList_21_Merge_Two_Sorted_Lists

Problem DiscriptionGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or eq

2017-06-01 21:15:39 177

空空如也

空空如也

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

TA关注的人

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