<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[Opium_Z的博客]]></title><description><![CDATA[]]></description><link>https://blog.csdn.net/Opium_Z</link><language>zh-cn</language><generator>https://blog.csdn.net/</generator><copyright><![CDATA[Copyright &copy; Opium_Z]]></copyright><item><title><![CDATA[Leetcode 75. Sort Colors]]></title><link>https://blog.csdn.net/Opium_Z/article/details/93725736</link><guid>https://blog.csdn.net/Opium_Z/article/details/93725736</guid><author>Opium_Z</author><pubDate>Wed, 26 Jun 2019 12:07:54 +0800</pubDate><description><![CDATA[Problem:

Analysis:
in place sort

This 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...]]></description><category></category></item><item><title><![CDATA[Leetcode 124. Binary Tree Maximum Path Sum]]></title><link>https://blog.csdn.net/Opium_Z/article/details/93697734</link><guid>https://blog.csdn.net/Opium_Z/article/details/93697734</guid><author>Opium_Z</author><pubDate>Wed, 26 Jun 2019 04:02:15 +0800</pubDate><description><![CDATA[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[...]]></description><category></category></item><item><title><![CDATA[Leetcode 518. Coin Change 2]]></title><link>https://blog.csdn.net/Opium_Z/article/details/93377715</link><guid>https://blog.csdn.net/Opium_Z/article/details/93377715</guid><author>Opium_Z</author><pubDate>Sun, 23 Jun 2019 08:32:20 +0800</pubDate><description><![CDATA[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];
...]]></description><category></category></item><item><title><![CDATA[Leetcode 322. Coin Change]]></title><link>https://blog.csdn.net/Opium_Z/article/details/93278508</link><guid>https://blog.csdn.net/Opium_Z/article/details/93278508</guid><author>Opium_Z</author><pubDate>Sat, 22 Jun 2019 04:53:25 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item><item><title><![CDATA[Leetcode 516  Longest Palindromic Subsequence]]></title><link>https://blog.csdn.net/Opium_Z/article/details/92044830</link><guid>https://blog.csdn.net/Opium_Z/article/details/92044830</guid><author>Opium_Z</author><pubDate>Sat, 15 Jun 2019 04:57:28 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item><item><title><![CDATA[Leetcode 309. Best Time to Buy and Sell Stock with Cooldown]]></title><link>https://blog.csdn.net/Opium_Z/article/details/91726036</link><guid>https://blog.csdn.net/Opium_Z/article/details/91726036</guid><author>Opium_Z</author><pubDate>Thu, 13 Jun 2019 04:07:23 +0800</pubDate><description><![CDATA[Problem:

Analysis:
DP is like induction prove.

define the base case
define the inductive rule


Code:
public int maxProfit(int[] prices) {
        
        if (prices == null || prices.length &lt;= ...]]></description><category></category></item><item><title><![CDATA[Leetcode 33 Search in Rotated Sorted Array]]></title><link>https://blog.csdn.net/Opium_Z/article/details/91708196</link><guid>https://blog.csdn.net/Opium_Z/article/details/91708196</guid><author>Opium_Z</author><pubDate>Thu, 13 Jun 2019 02:52:32 +0800</pubDate><description><![CDATA[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 =...]]></description><category></category></item><item><title><![CDATA[Leetcode Permutation]]></title><link>https://blog.csdn.net/Opium_Z/article/details/91177839</link><guid>https://blog.csdn.net/Opium_Z/article/details/91177839</guid><author>Opium_Z</author><pubDate>Fri, 07 Jun 2019 23:36:09 +0800</pubDate><description><![CDATA[Problem
Give a string, like “abc”, return all the possible combinations (all the chars are different)
example:
input: “abc”
output: [abc, acb, bac, bca, cab, cba]
Analysis
obviously, this problem can ...]]></description><category></category></item><item><title><![CDATA[Leetcode 200  Number of Islands]]></title><link>https://blog.csdn.net/Opium_Z/article/details/91127243</link><guid>https://blog.csdn.net/Opium_Z/article/details/91127243</guid><author>Opium_Z</author><pubDate>Fri, 07 Jun 2019 13:20:00 +0800</pubDate><description><![CDATA[Problem:

Analysis

scan grid to find ‘1’
if ‘1’, then dfs or bfs and label

Code
class Solution1 {
 // 1. scan grid   2.if ==1, dfs and label
    
    final static int[][] dirs = {{1,0},{-1,0},{0,1},...]]></description><category></category></item><item><title><![CDATA[LeetCode 496 -  Next Greater Element I]]></title><link>https://blog.csdn.net/Opium_Z/article/details/90993448</link><guid>https://blog.csdn.net/Opium_Z/article/details/90993448</guid><author>Opium_Z</author><pubDate>Thu, 06 Jun 2019 01:12:36 +0800</pubDate><description><![CDATA[quesion:

Analysis:
Two methods:

brute force:


find the poistion of each element of nums1 in nums2
search nums2 until find, or set as -1
time complexity O(nm), space O(m)


stack ,hashmap


fInd eac...]]></description><category></category></item><item><title><![CDATA[Machine Learning -- algorithms performance measure (heart disease data)]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89490946</link><guid>https://blog.csdn.net/Opium_Z/article/details/89490946</guid><author>Opium_Z</author><pubDate>Wed, 24 Apr 2019 13:30:21 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item><item><title><![CDATA[Machine Learning -- data visualizations--PCA (heart disease data)]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89485937</link><guid>https://blog.csdn.net/Opium_Z/article/details/89485937</guid><author>Opium_Z</author><pubDate>Wed, 24 Apr 2019 09:17:29 +0800</pubDate><description><![CDATA[OverView
In 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...]]></description><category></category></item><item><title><![CDATA[Machine Learning--Heart Disease Prediction 1]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89292421</link><guid>https://blog.csdn.net/Opium_Z/article/details/89292421</guid><author>Opium_Z</author><pubDate>Sun, 14 Apr 2019 06:30:41 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item><item><title><![CDATA[Leetcode 277 Find the Celebrity]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89171158</link><guid>https://blog.csdn.net/Opium_Z/article/details/89171158</guid><author>Opium_Z</author><pubDate>Wed, 10 Apr 2019 05:49:57 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item><item><title><![CDATA[Leetcode 91  Decode Ways]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89170347</link><guid>https://blog.csdn.net/Opium_Z/article/details/89170347</guid><author>Opium_Z</author><pubDate>Wed, 10 Apr 2019 04:58:28 +0800</pubDate><description><![CDATA[Problem:
A message containing letters from A-Z is being encoded to numbers using the following mapping:
‘A’ -&gt; 1
‘B’ -&gt; 2
…
‘Z’ -&gt; 26
Given a non-empty string containing only digits, determin...]]></description><category></category></item><item><title><![CDATA[Leetcode 199 Binary Tree Right Side View]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89051324</link><guid>https://blog.csdn.net/Opium_Z/article/details/89051324</guid><author>Opium_Z</author><pubDate>Sat, 06 Apr 2019 06:57:00 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item><item><title><![CDATA[Leetcode 503 Next Greater Element II]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89050636</link><guid>https://blog.csdn.net/Opium_Z/article/details/89050636</guid><author>Opium_Z</author><pubDate>Sat, 06 Apr 2019 03:26:07 +0800</pubDate><description><![CDATA[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 ...]]></description><category></category></item><item><title><![CDATA[Leetcode 219  Contains Duplicate II]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89019332</link><guid>https://blog.csdn.net/Opium_Z/article/details/89019332</guid><author>Opium_Z</author><pubDate>Thu, 04 Apr 2019 12:13:29 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item><item><title><![CDATA[Leetcode 450 Delete Node in a BST]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89011658</link><guid>https://blog.csdn.net/Opium_Z/article/details/89011658</guid><author>Opium_Z</author><pubDate>Thu, 04 Apr 2019 09:50:22 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item><item><title><![CDATA[Leetcode 652  Find Duplicate Subtrees]]></title><link>https://blog.csdn.net/Opium_Z/article/details/89010347</link><guid>https://blog.csdn.net/Opium_Z/article/details/89010347</guid><author>Opium_Z</author><pubDate>Thu, 04 Apr 2019 08:36:37 +0800</pubDate><description><![CDATA[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...]]></description><category></category></item></channel></rss>