自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Leetcode 75. Sort Colors

Problem:Analysis:in place sortThis question is actually a rainbow sort.Since we have 3 colors, we will need 3 pointers to denote 3 districts.It should be like the follows:a a | b b | x x x | c...

2019-06-26 12:07:54 122

原创 Leetcode 124. Binary Tree Maximum Path Sum

Problem:Analysis:In this problem, I gonna use DFS to solve it. By using recursion, we should set up the base rule and recursive rule.there is a small trick in this problem, we should pass the int[...

2019-06-26 04:02:15 103

原创 Leetcode 518. Coin Change 2

Problem:Analysis:The analysis is the same as the Coin Change 1 (see previous post)Code:public int change1(int amount, int[] coins) { int[][] f = new int[coins.length + 1][amount + 1];...

2019-06-23 08:32:20 104

原创 Leetcode 322. Coin Change

Problem:Analysis:Obviously, this is a DP problem. we can try to figure out it from two aspects. Top to bottom or bottom to Top.The next step, we should reduce the time complexity and space complex...

2019-06-22 04:53:25 122

原创 Leetcode 516 Longest Palindromic Subsequence

Problem:Analysis:DP 问题的核心就是转化为数学归纳法;如果可以画出图就更好了time O(n^2)space O(n^2)Code:public int longestPalindromeSubseq(String s) { if (s == null || s.length() == 0) return 0; if(s.len...

2019-06-15 04:57:28 86

原创 Leetcode 309. Best Time to Buy and Sell Stock with Cooldown

Problem:Analysis:DP is like induction prove.define the base casedefine the inductive ruleCode:public int maxProfit(int[] prices) { if (prices == null || prices.length <= ...

2019-06-13 04:07:23 102

原创 Leetcode 33 Search in Rotated Sorted Array

Problem:Analysis:This question can be transferred as the above figure.two scenarios: which represent by mid1 and mid2.Code:public int search(int[] nums, int target) { if (nums.length =...

2019-06-13 02:52:32 109

原创 Leetcode Permutation

ProblemGive a string, like “abc”, return all the possible combinations (all the chars are different)example:input: “abc”output: [abc, acb, bac, bca, cab, cba]Analysisobviously, this problem can ...

2019-06-07 23:36:09 197

原创 Leetcode 200 Number of Islands

Problem:Analysisscan grid to find ‘1’if ‘1’, then dfs or bfs and labelCodeclass Solution1 { // 1. scan grid 2.if ==1, dfs and label final static int[][] dirs = {{1,0},{-1,0},{0,1},...

2019-06-07 13:20:00 90

原创 LeetCode 496 - Next Greater Element I

quesion:Analysis:Two methods:brute force:find the poistion of each element of nums1 in nums2search nums2 until find, or set as -1time complexity O(nm), space O(m)stack ,hashmapfInd eac...

2019-06-06 01:12:36 106

原创 Machine Learning -- algorithms performance measure (heart disease data)

OverView:In this chapter, I’m gonna do performance stuffs for machine learning algorithms. From previous chapter, I have already built four model:SVM-RBF, SVM-PLOY, Bagging, AdaBoost.Step 1: Confus...

2019-04-24 13:30:21 261

原创 Machine Learning -- data visualizations--PCA (heart disease data)

OverViewIn this chapte, I will use PCA for data visualization. Visualizing 2 or 3 dimensional data is not that challenging, however, here we get 13 features.Now, I will use PCA to reduce that 13 di...

2019-04-24 09:17:29 465

原创 Machine Learning--Heart Disease Prediction 1

Source Information:( a ) Creators:– 1. Hungarian Institute of Cardiology. Budapest: Andras Janosi, M.D.– 2. University Hospital, Zurich, Switzerland: William Steinbrunn, M.D.– 3. University Hospit...

2019-04-14 06:30:41 657

原创 Leetcode 277 Find the Celebrity

Problem:Analysis:method1:first of all, we can use the array with 2 dimensions to check each pair, which time complexity will be O(n^2)method2:the first pass for all the people, find the celebri...

2019-04-10 05:49:57 84

原创 Leetcode 91 Decode Ways

Problem:A message containing letters from A-Z is being encoded to numbers using the following mapping:‘A’ -> 1‘B’ -> 2…‘Z’ -> 26Given a non-empty string containing only digits, determin...

2019-04-10 04:58:28 109

原创 Leetcode 199 Binary Tree Right Side View

Problem:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.Input: [1,2,3,null,5,null,4]Output: [1, 3, 4]E...

2019-04-06 06:57:00 87

原创 Leetcode 503 Next Greater Element II

Problem:Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the ...

2019-04-06 03:26:07 97

原创 Leetcode 219 Contains Duplicate II

Problem:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at...

2019-04-04 12:13:29 101

原创 Leetcode 450 Delete Node in a BST

Problem:Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically, the deletion can be div...

2019-04-04 09:50:22 96

原创 Leetcode 652 Find Duplicate Subtrees

Problem:Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them.Two trees are duplicate if they have the sam...

2019-04-04 08:36:37 108

翻译 Leetcode 17 Letter Combinations of a Phone Number

problem:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters is just like on the telephone butto...

2019-04-03 12:22:04 110

原创 Leetcode 56 Merge Intervals

Prolem:Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] ove...

2019-04-02 09:40:44 127

原创 LeetCode 23 Merge k Sorted Lists

Problem:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[1->4->5,1->3->4,2->6]Output: 1->1->2->3->4-...

2019-04-01 12:07:48 109

原创 Leetcode 220 Contains Duplicate III

Problem:Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute di...

2019-03-31 11:41:24 119

原创 LeetCode 138 Copy List with Random Pointer

Problem:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Analyse:First of all, we should know what is deep copy and...

2019-03-30 05:45:21 109

原创 LeetCode 161 One Edit Distance

Problem:Given two strings S and T, determine if they are both one edit distance apart.Analyse:delete, add, replace 都是one edit distance.delete 和 add: 两个string 的长度相差一replace: 两个string的长度相同伪代码:str...

2019-03-30 00:18:12 122

原创 Leetcode 253: meeting room

Arrang classes, you’re gonna figure out the min classroom required.input: [0, 30],[5, 10],[15, 20]output: 2Java:/* * public class Interval { int start; int end; public Interval() { this....

2019-03-10 03:39:18 373

原创 Find the k nearest point from the origin

Find the k nearest point from the origin---FaceBook 一轮电面 There are some locations, find the K nearest oneJavaThere are some locations, find the K nearest oneinput: [1,1],[2,3],[-1,-1], k=2output:[1...

2019-03-10 03:10:59 141

空空如也

空空如也

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

TA关注的人

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