<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[ljf_study的博客]]></title><description><![CDATA[show me the code ...]]></description><link>https://blog.youkuaiyun.com/ljf_study</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; ljf_study]]></copyright><item><title><![CDATA[按之字形顺序打印二叉树/把二叉树打印成多行]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/103369055</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/103369055</guid><author>ljf_study</author><pubDate>Tue, 03 Dec 2019 16:02:24 +0800</pubDate><description><![CDATA[按之字形顺序打印二叉树
题目描述
请实现一个函数按照之字形打印二叉树，即第一行按照从左到右的顺序打印，第二层按照从右至左的顺序打印，第三行按照从左到右的顺序打印，其他行以此类推。
解题思路

可以用一个队列和一个flag来表示
flag用来表示是奇数层还是偶数层（根节点是第0层）
如果是偶数层，vector翻转插入即可
当前层的size记录好就可以正确表示

/*
struct TreeNode ...]]></description><category></category></item><item><title><![CDATA[对称的二叉树]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/103367670</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/103367670</guid><author>ljf_study</author><pubDate>Tue, 03 Dec 2019 15:07:36 +0800</pubDate><description><![CDATA[对称的二叉树
题目描述
请实现一个函数，用来判断一颗二叉树是不是对称的。注意，如果一个二叉树同此二叉树的镜像是同样的，定义其为对称的。
解题思路

递归的思路
递归停止的条件，走到叶子节点的子节点，如果传入的两个节点都为空，证明此时是对称的
如果这个节点的左孩子不等于右孩子 || 右孩子不等于左孩子 就不可能是对称的

/*
struct TreeNode {
    int val;
    s...]]></description><category></category></item><item><title><![CDATA[删除链表中重复的结点]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/103364814</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/103364814</guid><author>ljf_study</author><pubDate>Tue, 03 Dec 2019 11:59:44 +0800</pubDate><description><![CDATA[删除链表中重复的结点
题目描述
在一个排序的链表中，存在重复的结点，请删除该链表中重复的结点，重复的结点不保留，返回链表头指针。 例如，链表1-&gt;2-&gt;3-&gt;3-&gt;4-&gt;4-&gt;5 处理后为 1-&gt;2-&gt;5
解题思路

设置三个指针，p,q, r -&gt; 前驱，当前，后继
如果q-&gt;val != r -&gt; val,三个指针同时往后移一位...]]></description><category></category></item><item><title><![CDATA[扑克牌顺子]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/103363515</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/103363515</guid><author>ljf_study</author><pubDate>Tue, 03 Dec 2019 11:07:23 +0800</pubDate><description><![CDATA[扑克牌顺子
题目描述
LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张_)…他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他决定去买体育彩票,嘿嘿！！“红心A,黑桃3,小王,大王,方片5”,“Oh My God!”不是顺子…LL不高兴了,他想了想,决定大\小 王可以看成任何数字,并且A看作1,J为11,Q为12,K为13...]]></description><category></category></item><item><title><![CDATA[链表中环的入口结点]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/103338973</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/103338973</guid><author>ljf_study</author><pubDate>Sun, 01 Dec 2019 20:31:33 +0800</pubDate><description><![CDATA[链表中环的入口结点
题目描述
给一个链表，若其中包含环，请找出该链表的环的入口结点，否则，输出null。
解题思路
链表中，用快慢两指针，

首先确定是否链表中有环
如果快指针先到了链表的结尾，则肯定没有环
否则，快慢指针一定会相遇
然后慢指针置头结点，一步一步走，两个指针再次相遇的节点，即为链表中的环的入口
当fast == slow时，假设slow走过x个节点，则fast走过2x个节点。设环中...]]></description><category></category></item><item><title><![CDATA[圆圈中最后剩下的数]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/103338324</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/103338324</guid><author>ljf_study</author><pubDate>Sun, 01 Dec 2019 19:41:16 +0800</pubDate><description><![CDATA[题目描述
每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此。HF作为牛客的资深元老,自然也准备了一些小游戏。其中,有个游戏是这样的:首先,让小朋友们围成一个大圈。然后,他随机指定一个数m,让编号为0的小朋友开始报数。每次喊到m-1的那个小朋友要出列唱首歌,然后可以在礼品箱中任意的挑选礼物,并且不再回到圈中,从他的下一个小朋友开始,继续0…m-1报数…这样下去…直到剩下最后一...]]></description><category></category></item><item><title><![CDATA[二叉树的镜像]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/103336846</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/103336846</guid><author>ljf_study</author><pubDate>Sun, 01 Dec 2019 17:07:22 +0800</pubDate><description><![CDATA[二叉树的镜像
思路

如果当前节点为空，肯定就直接返回了
如果当前左右节点都为空，肯定也直接返回了
如果当前左右子节点为非空，交换两个左右子节点即可
递归左右子树来做

/*
struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x) :
			val(x), left(...]]></description><category></category></item><item><title><![CDATA[判断B是不是A的子结构]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/103336347</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/103336347</guid><author>ljf_study</author><pubDate>Sun, 01 Dec 2019 16:31:39 +0800</pubDate><description><![CDATA[题目描述
输入两棵二叉树A，B，判断B是不是A的子结构。（ps：我们约定空树不是任意一个树的子结构）
解题思路

需要两个函数的递归，第一个是Root1与Root2节点相等，然后递归两个节点下面的左右节点，即DoesTree1HasTree2函数完成的。
如果不相等，就要递归Root1的左右子树再与Root2进行比较
代码参考书籍

/*
struct TreeNode {
	int val;
	...]]></description><category></category></item><item><title><![CDATA[leetcode 207. Course Schedule 图，检查有无环，拓扑序列]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101440079</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101440079</guid><author>ljf_study</author><pubDate>Thu, 26 Sep 2019 14:15:57 +0800</pubDate><description><![CDATA[There are a total of n courses you have to take, labeled from 0 to n-1.
Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:...]]></description><category></category></item><item><title><![CDATA[leetcode 221. Maximal Square [dp]]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101268249</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101268249</guid><author>ljf_study</author><pubDate>Tue, 24 Sep 2019 10:20:04 +0800</pubDate><description><![CDATA[Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.
Example:
Input:
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
Output: 4
class Solution {
pu...]]></description><category></category></item><item><title><![CDATA[leetcode l236. Lowest Common Ancestor of a Binary Tree]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101266630</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101266630</guid><author>ljf_study</author><pubDate>Tue, 24 Sep 2019 09:52:31 +0800</pubDate><description><![CDATA[Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p a...]]></description><category></category></item><item><title><![CDATA[leetcode 208. Implement Trie (Prefix Tree)]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101265334</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101265334</guid><author>ljf_study</author><pubDate>Tue, 24 Sep 2019 09:26:33 +0800</pubDate><description><![CDATA[Implement a trie with insert, search, and startsWith methods.
Example:
Trie trie = new Trie();
trie.insert(“apple”); trie.search(“apple”);                               // returns true
trie.search(“a...]]></description><category></category></item><item><title><![CDATA[leetcode 139. Word Break [dp]]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101263115</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101263115</guid><author>ljf_study</author><pubDate>Tue, 24 Sep 2019 08:42:50 +0800</pubDate><description><![CDATA[Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
Note:
The sa...]]></description><category></category></item><item><title><![CDATA[leetcode 621. Task Scheduler]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101193393</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101193393</guid><author>ljf_study</author><pubDate>Mon, 23 Sep 2019 09:24:34 +0800</pubDate><description><![CDATA[Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each task could...]]></description><category></category></item><item><title><![CDATA[leetcode 49. Group Anagrams [map + sort]]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101191935</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101191935</guid><author>ljf_study</author><pubDate>Mon, 23 Sep 2019 08:43:53 +0800</pubDate><description><![CDATA[Given an array of strings, group anagrams together.

Input: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],
Output:
[
[“ate”,“eat”,“tea”],
[“nat”,“tan”],
[“bat”]
]

class Solution {
public:
    vector&lt;...]]></description><category></category></item><item><title><![CDATA[leetcode 399. Evaluate Division (图 + DFS)]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101191422</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101191422</guid><author>ljf_study</author><pubDate>Mon, 23 Sep 2019 08:24:30 +0800</pubDate><description><![CDATA[Evaluate Division


Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the ans...]]></description><category></category></item><item><title><![CDATA[leetcode 494. Target Sum]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101172849</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101172849</guid><author>ljf_study</author><pubDate>Sun, 22 Sep 2019 21:19:11 +0800</pubDate><description><![CDATA[Target Sum

You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.
Find...]]></description><category></category></item><item><title><![CDATA[39. Combination Sum （DFS递归）]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101170024</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101170024</guid><author>ljf_study</author><pubDate>Sun, 22 Sep 2019 19:57:40 +0800</pubDate><description><![CDATA[class Solution {
public:
    vector&lt;vector&lt;int&gt;&gt; combinationSum(vector&lt;int&gt;&amp; candidates, int target) {
        vector&lt;vector&lt;int&gt;&gt; res;
        vector&lt;int&gt; out;...]]></description><category></category></item><item><title><![CDATA[647. Palindromic Substrings （ ）]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101168478</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101168478</guid><author>ljf_study</author><pubDate>Sun, 22 Sep 2019 19:11:44 +0800</pubDate><description><![CDATA[class Solution {
public:
    int count = 0;
    int countSubstrings(string s) {
        for(int i = 0; i &lt; s.size(); i++){
            fun_helper(s, i, i);        //分两种情况，以自己为中心往两边扩散
            fu...]]></description><category></category></item><item><title><![CDATA[200. Number of Islands dfs求解]]></title><link>https://blog.youkuaiyun.com/ljf_study/article/details/101161534</link><guid>https://blog.youkuaiyun.com/ljf_study/article/details/101161534</guid><author>ljf_study</author><pubDate>Sun, 22 Sep 2019 16:04:18 +0800</pubDate><description><![CDATA[class Solution {
public
    int numIslands(vector&lt;vector&lt;char&gt;&gt;&amp; grid) {
        int n = grid.size();
        if(grid.size() &lt;= 0){
            return 0;
        }
        int m = g...]]></description><category></category></item></channel></rss>