<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Iris S on Medium]]></title>
        <description><![CDATA[Stories by Iris S on Medium]]></description>
        <link>https://medium.com/@xyzadek?source=rss-b909b48f3cc4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sQjtbYCJSFcdVTU1fOEW8Q.jpeg</url>
            <title>Stories by Iris S on Medium</title>
            <link>https://medium.com/@xyzadek?source=rss-b909b48f3cc4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 18:48:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@xyzadek/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Vocabulary]]></title>
            <link>https://xyzadek.medium.com/vocabulary-4449409e0f56?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4449409e0f56</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Thu, 23 Mar 2023 16:01:07 GMT</pubDate>
            <atom:updated>2023-03-23T16:01:07.916Z</atom:updated>
            <content:encoded><![CDATA[<img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4449409e0f56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Case class]]></title>
            <link>https://xyzadek.medium.com/case-class-a1a3fcb16a59?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1a3fcb16a59</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Tue, 07 Feb 2023 04:04:57 GMT</pubDate>
            <atom:updated>2023-02-07T04:04:57.644Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>promote parameter to field</li><li>sensible to string</li><li>equals and hashcode implemented out-of-the-box</li></ol><p>4. have copy() method</p><p>5. have companion object</p><p>6. serializable. can send instance of case class in between JVM</p><p>7. have extractor pattern</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1a3fcb16a59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scala — OOP Basic]]></title>
            <link>https://xyzadek.medium.com/scala-oop-basic-36d3b36e3ed3?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/36d3b36e3ed3</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 04:08:03 GMT</pubDate>
            <atom:updated>2023-03-25T19:00:00.764Z</atom:updated>
            <content:encoded><![CDATA[<h4>Object-Oriented Basics</h4><p>Constructors</p><pre>class Person(name: String, age: Int) // This is the constructor<br><br>val person = new Person(&quot;iris&quot;, 99)// a new person is constructed</pre><p>Difference between class parameter and class member</p><ul><li>class parameters are not fields</li><li>class members can be accessed by a “.”</li><li>to convert parameter &gt; field: var &amp; val definition inside of class are fields</li></ul><p>“This” keyword</p><ul><li>“this” access the method field incase there are same class property name and method property name</li></ul><p>Overloading</p><ul><li>overloading — defining method with the same name but different signature.</li><li>compiler will get confused when fields are same, but return type is different.</li><li>used def this() to overload constructor</li></ul><p>Immutability</p><ul><li>extremely important in functional programming</li><li>says that an instance is fixed, and cannot be modified.</li><li>whenever we need to modify the content of an instance, we need to return a new instance with the modified content</li></ul><h4>Syntactic Sugar: Method Notations</h4><p>when an apply() method is defined, when a class is called as a method, the compiler looks for the definition of apply() inside of the class, and execute.</p><h4>Scala Objects</h4><ul><li>class level functio<strong>nal</strong>ity (static)</li><li>means an instance of the object can access the class level definition</li><li>scala does not have class level functionality</li><li>in scala, to use class level definition, we use object as a singleton instance. for example, we define the type of the person object, and that is the only instance.</li><li>the advantage: scala objects are singleton instance by definition</li><li>a common pattern — companions:</li></ul><p>In order to separate class and instance level functionality</p><ul><li>companion design pattern — write object and class in the same file or same scope to split static(class) and instance level functionality</li></ul><p>Factory Method</p><ul><li>inside an object. to build an object like a constructor</li></ul><h4>Inheritance</h4><ul><li>Scala offers single class inheritance</li><li><strong>private</strong> will mark a method within its own class</li><li>protected will mark a method as accessible within its own and subclasses</li><li>seal will mark a method as accessible within the same file ONLY</li></ul><p>Overriding</p><ul><li>directly specify in the constructor</li><li>or overriding inside the class definition</li><li>all instances of derived classes will use the most recent definition</li></ul><p>Polymorphism</p><ul><li>a method call will go to the most overridden definition</li></ul><p>Prevent override</p><ul><li>use final keyword on member to prevent override</li><li>use final on entire class</li><li>seal class</li></ul><p>Abstract data types</p><p>Meaning of abstract</p><ul><li>for the situation we leave the definition of method and field blank or unimplemented</li><li>abstract class cannot be inistantiate</li><li>to extend an abstract class, provide a definition</li><li>both abstract classes and traits can have either abstract or non-abstract members</li></ul><p>Trait</p><ul><li>the ultimate abstract data type</li><li>describe behavior of a class</li><li>can be inherited along with classes</li><li>do not have constructor parameters</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36d3b36e3ed3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scala Basics]]></title>
            <link>https://xyzadek.medium.com/scala-beginners-4bf28ced308b?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bf28ced308b</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Sun, 06 Nov 2022 02:32:02 GMT</pubDate>
            <atom:updated>2023-01-05T18:40:26.167Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Val vs. Var</strong></p><ul><li>vals are immutable; cannot be re-assgin</li><li>compiler can infer types</li><li>vars can be re-assign</li></ul><p>Expressions</p><pre>val x = 1 + 2 // EXPRESSION</pre><ul><li>instruction vs. expression</li><li>scala forces everything to be an Zexpression</li></ul><pre>val condition = true<br>val conditionValue =. if condition 5 else 3 // IF EXPRESSION</pre><p><strong>Called-by-Value VS. Called-by-Name</strong></p><pre>object CBNvsCBV extends App {</pre><pre>def calledByValue(x: Long): Unit = {<br>    <em>println</em>(&quot;by value: &quot; + x) // timestamp<br>    <em>println</em>(&quot;by value: &quot; + x) // timestamp<br>  }<br><br>  def calledByName(x: =&gt; Long): Unit = {<br>    <em>println</em>(&quot;by name: &quot; + x) // timestamp1<br>    <em>println</em>(&quot;by name: &quot; + x) // timestamp2<br>  }<br><br>  <em>calledByValue</em>(1257387745764245L)<br>  <em>calledByName</em>(System.<em>nanoTime</em>())<br><br>  def infinite(): Int = 1 + <em>infinite</em>()<br>  def printFirst(x: Int, y: =&gt; Int) = <em>println</em>(x)<br><br>  //  printFirst(infinite(), 34) // stack overflow<br>  <em>printFirst</em>(34, <em>infinite</em>())<br>}</pre><h4><strong>Difference:</strong></h4><p>By Value: evaluate <strong>System.<em>nanoTime</em>() first, and use the value throughout the execution</strong></p><p>By Name: evaluate <strong>System.<em>nanoTime</em>() each time</strong></p><ul><li>lazy evaluation: if the parameter called by name is never used, it will never be evaluated</li></ul><h4>Useful When:</h4><ul><li>Lazy stream</li><li>Exception handling with the Try type</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bf28ced308b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Binary Tree] 二叉树题型分析]]></title>
            <link>https://xyzadek.medium.com/binary-tree-%E4%BA%8C%E5%8F%89%E6%A0%91%E9%A2%98%E5%9E%8B%E5%88%86%E6%9E%90-d60548aae3d0?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d60548aae3d0</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Fri, 18 Mar 2022 05:25:22 GMT</pubDate>
            <atom:updated>2022-03-18T15:18:52.058Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4HC_0R0TGbvdqdSSb3j-xQ.png" /></figure><p>思考重点：分治法</p><ul><li>二叉树题目几乎全部都要利用分治和递归的思想</li></ul><p>简单地解释一下分治法（Divide and Conqueror)</p><p><em>以下解释来自https://www.cnblogs.com/steven_oyj/archive/2010/05/22/1741370.html</em></p><ul><li>分治法的设计思想是：将一个难以直接解决的大问题，分割成一些规模较小的相同问题，以便各个击破，分而治之。</li><li>分治策略是：对于一个规模为n的问题，若该问题可以容易地解决（比如说规模n较小）则直接解决，否则将其分解为k个规模较小的子问题，这些子问题互相独立且与原问题形式相同，递归地解这些子问题，然后将各子问题的解合并得到原问题的解。这种算法设计策略叫做分治法。</li></ul><p>分治法在二叉树题目上的运用</p><ul><li>根据题目，思考左节点与右节点的关系，并推理出解题所需要返回的值 / 改变的变量</li><li>分别往左子树和右子树递归</li><li>确定base case</li></ul><blockquote>二叉树题目里面，常出现的分析场景和应对方案</blockquote><ol><li>询问最大/最小子树</li></ol><ul><li>定义全局变量去储存最大/最小子树的和</li><li>通过left + right + root.val 来获取当前子树的值，并和全局变量做比较</li><li>更新全局变量</li></ul><p>2. 通过左右子树的位置来搜索A和B节点的LCA</p><p>通过A和B的位置来推算LCA的位置</p><ul><li>当A或B 等于根，返回根</li><li>当B是A子树的一部分，而A是左子树的一部分，返回左子树；vice versa</li><li>当A和B分别在左子树和右子树，返回当前的根</li></ul><p>3. 验证当前树是否平衡</p><p>从最小子树开始，通过左子树和右子树的关系来推测平衡性</p><ul><li>返回三个变量：左右子树的值，左右子树的高度，当前根</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d60548aae3d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DP规律总结]]></title>
            <link>https://xyzadek.medium.com/dp%E8%A7%84%E5%BE%8B%E6%80%BB%E7%BB%93-68fb71894830?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/68fb71894830</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Mon, 03 Jan 2022 02:25:15 GMT</pubDate>
            <atom:updated>2022-01-03T02:27:12.872Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>背包型</strong></h4><h4><strong>前缀型</strong></h4><p><strong>划分型</strong></p><p>使用一维数组dp[i]: 记录在下标为i的元素前砍一刀所得到的方案数/可行性</p><ul><li>decode ways 在i砍一刀，求组合，累加全部方案总数</li><li>word break 在i砍一刀，看看能不能划分成单词</li></ul><p><strong>匹配型</strong></p><p>使用二维数组dp[i][j]记录两个string之间的关系：</p><p>例1. dp[i][j] = s[0:i] 能够和 p[0:j]匹配的最长string</p><p>例2. dp[i][j] = s[0:i]通过多少次能够变成p[0:j]</p><ul><li>wildcard matching</li><li>edit distance</li></ul><p><strong>区间型</strong></p><p>有substring, subarray等字眼</p><p>使用二维数组dp[i][j]记录两个区间所代表的最优值/可行性/方案总数</p><p><strong>接龙型</strong></p><ul><li>使用一维数组dp[i]: 以下标为i的元素结尾的最长长度</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68fb71894830" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[双指针总结]]></title>
            <link>https://xyzadek.medium.com/%E5%8F%8C%E6%8C%87%E9%92%88%E6%80%BB%E7%BB%93-18426ed5c7b4?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/18426ed5c7b4</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Tue, 28 Dec 2021 05:16:09 GMT</pubDate>
            <atom:updated>2021-12-28T05:16:09.355Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Substring系列</strong></p><p>找At least K个数</p><ul><li>用for loop移动右指针，左指针只在通过某些条件的情况下移动</li><li>每一轮for loop都累加当前count，通过某些条件的情况下给count++</li><li>Substring With At Least K Distinct Characters — <a href="https://www.lintcode.com/problem/1375/description">https://www.lintcode.com/problem/1375/description</a></li></ul><p><strong>Replacement系列</strong></p><p>滑动窗口 — 利用最大窗口特性</p><ul><li>用max, min来记录合法string长度</li><li>用k+单个字母最大出现次数来定义最大的窗口长度</li><li>移动左指针来缩小窗口</li></ul><p><a href="https://www.lintcode.com/problem/1246/">LintCode 炼码</a></p><p><strong>技巧</strong></p><ul><li>hash table来储存某个字母出现的次数，当次数为0时，进行某些操作</li><li>每一轮移动右指针一步，左指针只能在条件允许时移动</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18426ed5c7b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[二叉树与分治法总结]]></title>
            <link>https://xyzadek.medium.com/%E4%BA%8C%E5%8F%89%E6%A0%91%E4%B8%8E%E5%88%86%E6%B2%BB%E6%B3%95%E6%80%BB%E7%BB%93-6a8699660da3?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a8699660da3</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Tue, 21 Dec 2021 14:07:55 GMT</pubDate>
            <atom:updated>2021-12-21T21:18:11.191Z</atom:updated>
            <content:encoded><![CDATA[<p>知识点</p><p><strong>找最接近的数：BST左右间隔的范围缩窄</strong></p><ul><li>Closest Binary Search Tree Value II — <a href="https://www.lintcode.com/problem/901/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/901/?_from=collection&amp;fromId=161</a></li></ul><p><strong>追踪最大/最小值</strong></p><ul><li>max(left, right) + 1 来追踪最长路径</li></ul><p>Maximum Depth of Binary Tree — <a href="https://www.lintcode.com/problem/97/description?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/97/description?_from=collection&amp;fromId=161</a></p><p><strong>通过返回多个变量来判断条件</strong></p><ul><li>Validate binary search tree — <a href="https://www.lintcode.com/problem/95/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/95/?_from=collection&amp;fromId=161</a></li><li>Balanced Binary Tree — <a href="https://www.lintcode.com/problem/93/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/93/?_from=collection&amp;fromId=161</a></li><li>Lowest Common Ancestor III — <a href="https://www.lintcode.com/submission/27303984/?action_type=1">https://www.lintcode.com/submission/27303984/?action_type=1</a></li></ul><p>插入/删除新节点</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a8699660da3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DFS规律总结]]></title>
            <link>https://xyzadek.medium.com/dfs%E8%A7%84%E5%BE%8B%E6%80%BB%E7%BB%93-e3c67fee55f8?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3c67fee55f8</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Tue, 21 Dec 2021 14:05:20 GMT</pubDate>
            <atom:updated>2021-12-26T19:38:55.204Z</atom:updated>
            <content:encoded><![CDATA[<p>排列Permutation</p><ul><li>基本排列（不能调用自己；不用去重）</li></ul><p>Permutations — <a href="https://www.lintcode.com/problem/15/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/15/?_from=collection&amp;fromId=161</a></p><ul><li>排列去重（先用蓝后用绿例子；不可重复调用自己；visited + num[i]==num[i-1]）</li></ul><p>String Permutation II — <a href="https://www.lintcode.com/problem/10/">https://www.lintcode.com/problem/10/</a></p><p>组合Combination</p><ul><li>组合去重（不能重复调用自己） （num[i+1:]例子）</li></ul><p>k sum ii —</p><ul><li>组合去重（可以重复调用自己，但后续元素不能调用前面的元素）</li></ul><p>Combination Sum — <a href="https://www.lintcode.com/problem/135/">https://www.lintcode.com/problem/135/</a></p><p><strong>字符串切割</strong></p><ul><li>切出长度为x的字符串</li><li>不断尝试切割直到匹配到某种规律</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3c67fee55f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BFS 规律总结]]></title>
            <link>https://xyzadek.medium.com/bfs-%E8%A7%84%E5%BE%8B%E6%80%BB%E7%BB%93-ef0f1f2b21f9?source=rss-b909b48f3cc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef0f1f2b21f9</guid>
            <dc:creator><![CDATA[Iris S]]></dc:creator>
            <pubDate>Sun, 19 Dec 2021 20:43:46 GMT</pubDate>
            <atom:updated>2021-12-20T20:02:24.352Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>二维坐标型</strong></p><p>最短路径</p><ul><li>从单个点开始向四方搜索</li><li>无脑前进+最短路径 + Dijkastra: The Maze I &amp; II <a href="https://www.lintcode.com/problem/788/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/788/?_from=collection&amp;fromId=161</a></li><li>二维/一维数组转换+最短路径</li></ul><p>Sliding Puzzle <a href="https://www.lintcode.com/problem/794/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/794/?_from=collection&amp;fromId=161</a></p><p>查找可行性</p><ul><li>从多个点开始，分层向四方搜索</li></ul><p>Zombie in matrix — <a href="https://www.lintcode.com/problem/598/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/598/?_from=collection&amp;fromId=161</a></p><p><strong>一维坐标型</strong></p><ul><li>string重构，匹配</li></ul><p>Sequence Reconstruction — <a href="https://www.lintcode.com/problem/605/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/605/?_from=collection&amp;fromId=161</a></p><p>Remove substring — <a href="https://www.lintcode.com/problem/624/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/624/?_from=collection&amp;fromId=161</a></p><p>建图型</p><ul><li>Graph Valid Tree — <a href="https://www.lintcode.com/problem/178/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/178/?_from=collection&amp;fromId=161</a></li><li>Connected components in undirected graph <a href="https://www.lintcode.com/problem/431/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/431/?_from=collection&amp;fromId=161</a></li></ul><p>拓扑序型</p><p>Alien Dictionary — <a href="https://www.lintcode.com/problem/892/?_from=collection&amp;fromId=161">https://www.lintcode.com/problem/892/?_from=collection&amp;fromId=161</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef0f1f2b21f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>