<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Andy</title>
    <description></description>
    <link>https://CornPrincess.github.io/</link>
    <atom:link href="https://CornPrincess.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sat, 04 Jan 2020 15:58:41 +0000</pubDate>
    <lastBuildDate>Sat, 04 Jan 2020 15:58:41 +0000</lastBuildDate>
    <generator>Jekyll v3.8.5</generator>
    
      <item>
        <title>JavaScript传递参数</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#相关概念&quot; id=&quot;markdown-toc-相关概念&quot;&gt;相关概念&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#复制变量的值&quot; id=&quot;markdown-toc-复制变量的值&quot;&gt;复制变量的值&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#复制基本类型的值&quot; id=&quot;markdown-toc-复制基本类型的值&quot;&gt;复制基本类型的值&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#复制引用类型的值&quot; id=&quot;markdown-toc-复制引用类型的值&quot;&gt;复制引用类型的值&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#传递参数&quot; id=&quot;markdown-toc-传递参数&quot;&gt;传递参数&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#传递基本类型参数&quot; id=&quot;markdown-toc-传递基本类型参数&quot;&gt;传递基本类型参数&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#传递引用类型参数&quot; id=&quot;markdown-toc-传递引用类型参数&quot;&gt;传递引用类型参数&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#对比其他语言&quot; id=&quot;markdown-toc-对比其他语言&quot;&gt;对比其他语言&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#java&quot; id=&quot;markdown-toc-java&quot;&gt;Java&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#参考&quot; id=&quot;markdown-toc-参考&quot;&gt;参考&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  ECMAScript 中所有函数的参数都是按值传递。也就是说，把函数外部的值复制给函数内部的参数，就和把值从一个变量复制到另一个变量一样 ——《JavaScript高级程序设计（第三版）》
&lt;/blockquote&gt;

本篇博客将围绕书中这一知识点进行深入分析。

&lt;h1 id=&quot;相关概念&quot;&gt;相关概念&lt;/h1&gt;
&lt;blockquote&gt;
  首先要弄清楚一些概念：变量、值、值的类型、引用、对象。如果这些概念没搞清楚，就没办法讨论这个问题。
  &lt;ul&gt;
    &lt;li&gt;&lt;strong&gt;变量&lt;/strong&gt;：变量就是一个定义在某个作用域的名字(name)，它是一个identifier。它绑定(bind)了一块内存。&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;值&lt;/strong&gt;：值就是变量绑定的那块内存里面存放的数据。至于存放的数据的具体代表什么(含义是什么)，暂且不管。但是本质上就是一段二进制数。&lt;/li&gt;
    &lt;li&gt;&lt;strong&gt;值的类型&lt;/strong&gt;：即变量绑定的那块内存里放的数据应该如何去解释，或者说如何解码。在JS中值的类型有很多种，但是可以归结成两类：基本类型和引用类型。基本类型就是说：变量绑定的那块内存里放的数据的含义就是它看起来的那个样子。引用类型就是说：变量绑定的那块内存里放的数据，并不是我真正想要的数据，它是一个元数据、一个地址，一个指向我真正想用的数据的位置的指针。&lt;/li&gt;
    &lt;li&gt;引用：指向对象的指针&lt;/li&gt;
    &lt;li&gt;对象：上面说的那些不能被变量直接绑定，而是要通过引用来间接绑定的数据就是对象。而且对象数据与非变量数据相比有一个特点，即它是有内部结构的，即属性。&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

ECMAScript 变量包含两种不同的数据类型的值：基本类型值和引用类型值，其中基本类型值是&lt;strong&gt;按值访问&lt;/strong&gt;的，引用类型值&lt;strong&gt;按引用访问&lt;/strong&gt;。

&lt;h1 id=&quot;复制变量的值&quot;&gt;复制变量的值&lt;/h1&gt;

&lt;h2 id=&quot;复制基本类型的值&quot;&gt;复制基本类型的值&lt;/h2&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;let num1 = 5;
let num2 = num1;
&lt;/code&gt;&lt;/pre&gt;

复制后变量对象：
| 变量  |       值       |
| :—: | :————: |
| num1  | 5 (Number类型) |
| num2  | 5 (Number类型) |

复制后，num1与num2中的值相互独立，不会相互影响。

&lt;h2 id=&quot;复制引用类型的值&quot;&gt;复制引用类型的值&lt;/h2&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;var a = new Object();
var b = a;
a.name = 'Alice';
console.log(b.name); // Alice
&lt;/code&gt;&lt;/pre&gt;

复制后变量对象：
| 变量  |           值           |
| :—: | :——————–: |
|   a   | reference (Object类型) |
|   b   | reference (Object类型) |

复制引用类型时，同样也是阿静存储在变量对象中的值复制一份放到新变量的空间，不同的是，复制的值实际上是一个指针，会指向同一个对象。，所在上述代码中对b对应的对象进行改变，a对应的对象也被影响到。

&lt;h1 id=&quot;传递参数&quot;&gt;传递参数&lt;/h1&gt;

弄清楚了上面的概念，我们再来理解&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ECMAScript中所有函数的参数都是按值传递的&lt;/code&gt;，还是看原书的示例代码

&lt;h2 id=&quot;传递基本类型参数&quot;&gt;传递基本类型参数&lt;/h2&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;function addTen(num) {
    num += 10;
    return num;
}

var count = 20
var result = addTen(count);
alert(count);    //20
alert(result);   //10
&lt;/code&gt;&lt;/pre&gt;
可以看到，在基本类型中，count并没有因为addTen(count)而发送改变，证明参数确实是按值传递的，如果参数按引用传递，那么count也会跟着+10，变为30

&lt;h2 id=&quot;传递引用类型参数&quot;&gt;传递引用类型参数&lt;/h2&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;function setName(obj) {
    obj.name = &quot;Nicholas&quot;;
    obj = new Object();
    obj.name = &quot;Alice&quot;
}

var person = new Object();
setName(person);
alert(person.name);    //&quot;Nicholas&quot;
&lt;/code&gt;&lt;/pre&gt;

以上代码可以证明传递引用类型参数时也是按值传递的，因为在setName方法中，及时给obj赋值一个新对象但并没有改变入参person的引用。

&lt;h1 id=&quot;对比其他语言&quot;&gt;对比其他语言&lt;/h1&gt;

&lt;h2 id=&quot;java&quot;&gt;Java&lt;/h2&gt;
按值传递。

//  TODO

// TODO

&lt;h1 id=&quot;参考&quot;&gt;参考&lt;/h1&gt;

&lt;a href=&quot;https://segmentfault.com/q/1010000004970961&quot;&gt;怎么理解 JavaScript访问变量有按值和按引用两种方式&lt;/a&gt;
</description>
        <pubDate>Wed, 18 Dec 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/12/18/JavaScript-JavaScript%E4%BC%A0%E9%80%92%E5%8F%82%E6%95%B0/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/12/18/JavaScript-JavaScript%E4%BC%A0%E9%80%92%E5%8F%82%E6%95%B0/</guid>
        
        <category>JavaScript</category>
        
        
        <category>JavaScript</category>
        
      </item>
    
      <item>
        <title>JavaScript数据类型</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#类型&quot; id=&quot;markdown-toc-类型&quot;&gt;类型&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#null和undefined&quot; id=&quot;markdown-toc-null和undefined&quot;&gt;Null和Undefined&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#参考&quot; id=&quot;markdown-toc-参考&quot;&gt;参考&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

本篇博客主要记录JavaScript的数据类型相关的知识。

&lt;h1 id=&quot;类型&quot;&gt;类型&lt;/h1&gt;
查阅最新的&lt;a href=&quot;https://tc39.es/ecma262/#sec-ecmascript-data-types-and-values&quot;&gt;ECMAScript 2020&lt;/a&gt;可知，JavaScript一共有7种基本数据类型（primitives），Undefined、Null、Boolean、Number、&lt;strong&gt;BigInt（新加类型）&lt;/strong&gt;、String、Symbol，以及Object类型

我们从运行时的角度去看 JavaScript 的类型系统。&lt;strong&gt;运行时类型是代码实际执行过程中我们用到的类型&lt;/strong&gt;。所有的类型数据都会属于8个类型之一。从变量、参数、返回值到表达式中间结果，任何 JavaScript 代码运行过程中产生的数据，都具有运行时类型。

可以通过&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;typeof&lt;/code&gt;操作符进行类型的确认

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;undefined --- 值为定义
boolean --- 值为布尔值
string --- 值为字符串
number --- 值为数值
object --- 值为对象或null
function --- 值为函数
&lt;/code&gt;&lt;/pre&gt;

调用typeof null返回object，是因为特殊值null被认为是一个空的对象

&lt;h1 id=&quot;null和undefined&quot;&gt;Null和Undefined&lt;/h1&gt;

&lt;blockquote&gt;
  The value null is written with a literal: null. &lt;strong&gt;null is not an identifier for a property of the global object, like undefined can be.&lt;/strong&gt; &lt;strong&gt;Instead, null expresses a lack of identification, indicating that a variable points to no object.&lt;/strong&gt; In APIs, null is often retrieved in a place where an object can be expected but no object is relevant.
&lt;/blockquote&gt;

ECMAScript在第三版中引入&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;undefined&lt;/code&gt;，追要为了正式区分空对象指针（null）与未经初始化的变量（undefined）

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;// foo does not exist. It is not defined and has never been initialized:
foo; //ReferenceError: foo is not defined
//typeof foo --- undefined

// foo is known to exist now but it has no type or value:
var foo = null;
foo; //null  
//typeof foo --- object
&lt;/code&gt;&lt;/pre&gt;

对null和undefined进行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;==&lt;/code&gt;、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;===&lt;/code&gt;的测试，可以看到，实际上undefined值是派生自null值的，因此null == undefined返回true。

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;typeof null          // &quot;object&quot; (not &quot;null&quot; for legacy reasons)
typeof undefined     // &quot;undefined&quot;
null === undefined   // false
null  == undefined   // true
null === null        // true
null == null         // true
!null                // true
isNaN(1 + null)      // false
isNaN(1 + undefined) // true
&lt;/code&gt;&lt;/pre&gt;

如果定义的变量准备在将来保存对象，可以将变量初始化为null，这样只要直接检查null值，就可以进行对象的操作,体现&lt;strong&gt;null作为空指针的惯例&lt;/strong&gt;，也可以区分undefined

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;if (car != null) {
    // code 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;/*You can use undefined and the strict equality and inequality operators to determine whether a variable has a value. 
*/
// first alternative
var x;
if (x === undefined) {
   // these statements execute
}
else {
   // these statements do not execute
}

// x has not been declared before
if (typeof x === 'undefined') { // evaluates to true without errors
   // these statements execute
}

if (x === undefined) { // throws a ReferenceError

}

// second alternative
if ('x' in window) {
  // these statements execute only if x is defined globally 
}

// third alternative
var x;
if (x === void 0) {
   // these statements execute
}

// y has not been declared before
if (y === void 0) {
   // throws a - Uncaught ReferenceError: y is not defined
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id=&quot;参考&quot;&gt;参考&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://zhuanlan.zhihu.com/p/22557749&quot;&gt;如何更好的了解ECMAScript&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null&quot;&gt;Standard built-in objects - null&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined&quot;&gt;Standard built-in objects - undefined&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 17 Dec 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/12/17/JavaScript-JavaScript%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/12/17/JavaScript-JavaScript%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/</guid>
        
        <category>JavaScript</category>
        
        
        <category>JavaScript</category>
        
      </item>
    
      <item>
        <title>Chapter2 Command-Line</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#vi-editing-mode&quot; id=&quot;markdown-toc-vi-editing-mode&quot;&gt;vi Editing Mode&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-readline-startup-file&quot; id=&quot;markdown-toc-the-readline-startup-file&quot;&gt;The readline Startup File&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

This is exactly what bash allows you to do. It has editing modes that allow you to &lt;strong&gt;edit command lines with editing commands&lt;/strong&gt; similar to those of the two most popular UNIX editors, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vi&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;emacs&lt;/code&gt;. It also provides a much-extended analog to the C shell history mechanism called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fc&lt;/code&gt; (for fix command) that, among other things, allows you to use your favorite editor directly for editing your command lines. To round things out, bash also provides the original C shell history mechanism.

bash initially starts interactively with emacs-mode as the default, First, you can use the set command:
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; emacs

or:

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; vi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
The second way of selecting the editing mode is to set a readline variable in the file  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.inputrc&lt;/code&gt;.

&lt;h2 id=&quot;vi-editing-mode&quot;&gt;vi Editing Mode&lt;/h2&gt;

&lt;strong&gt;Editing commands in vi input mode&lt;/strong&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Command&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;DEL&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;Delete previous character&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;CTRL-W&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;Erase previous word (i.e., erase until a blank)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;CTRL-V&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;Quote the next character&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;ESC&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;Enter control mode (see below)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;strong&gt;Basic vi control mode commands&lt;/strong&gt;
|Command|Description|
|:–:|:–:|
|h|Move left one character|
|l|Move right one character|
|w|Move right one word|
|b|Move left one word|
|W|Move to beginning of next non-blank word|
|B|Move to beginning of preceding non-blank word|
|e|Move to end of current word|
|E|Move to end of current non-blank word|
|0|Move to beginning of line|
|^|Move to first non-blank character in line|
|$|Move to end of line|

&lt;strong&gt;Commands for entering vi input mode&lt;/strong&gt;
|Command|Description|
|:–:|:–:|
|i|Text inserted before current character (insert)|
|a|Text inserted after current character (append)|
|I|Text inserted at beginning of line|
|A|Text inserted at end of line|
|R|Text overwrites existing text|

&lt;strong&gt;Abbreviations for vi-mode delete commands&lt;/strong&gt;
|Command|Description|
|:–:|:–:|
|D|Equivalent to d$ (delete to end of line)|
|dd|Equivalent to 0d$ (delete entire line)|
|C|Equivalent to c$ (delete to end of line, enter input mode)|
|cc|Equivalent to 0c$ (delete entire line, enter input mode)|
|X|Equivalent to dl (delete character backwards)|
|x|Equivalent to dh (delete character forwards)|

&lt;strong&gt;vi control mode commands for searching the command history&lt;/strong&gt;
|Command|Description|
|:–:|:–:|
|k or -|Move backward one line|
|j or +|Move forward one line|
|G|Move to line given by repeat count|
|/string|Search backward for string|
|?string|Search forward for string|
|n|Repeat search in same direction as previous|
|N|Repeat search in opposite direction of previous|

** Miscellaneous vi-mode commands**
|Command|Description|
|:–:|:–:|
|~|Invert (twiddle) case of current character(s)|
|-|Append last word of previous command, enter input mode|
|CTRL-L|Clear the screen and redraw the current line on it; good for when your screen becomes garbled|
|#|Prepend # (comment character) to the line and send it to the history list; useful for saving a command to be executed later without having to retype it|

&lt;h2 id=&quot;the-readline-startup-file&quot;&gt;The readline Startup File&lt;/h2&gt;
The default startup file is called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.inputrc&lt;/code&gt; and must exist in your home directory if you wish to customize readline. You can change the default filename by setting the environment variable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;INPUTRC&lt;/code&gt;
</description>
        <pubDate>Thu, 04 Jul 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/07/04/Bash-Chapter2-Command-Line/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/07/04/Bash-Chapter2-Command-Line/</guid>
        
        <category>Command-Line</category>
        
        <category>vi</category>
        
        
        <category>Bash</category>
        
      </item>
    
      <item>
        <title>Chapter1 Bash Basics</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#what-is-a-shell&quot; id=&quot;markdown-toc-what-is-a-shell&quot;&gt;What is a Shell&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#history-of-unix-shells&quot; id=&quot;markdown-toc-history-of-unix-shells&quot;&gt;History of UNIX Shells&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#files&quot; id=&quot;markdown-toc-files&quot;&gt;Files&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#input-and-output&quot; id=&quot;markdown-toc-input-and-output&quot;&gt;Input and Output&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;what-is-a-shell&quot;&gt;What is a Shell&lt;/h2&gt;
A shell is any user interface to the UNIX operating system, i.e., any program that takes input from the user, translates it into instructions that the operating system can understand, and conveys the operating system’s output back to the user. 
&lt;img src=&quot;http://static.zybuluo.com/xiaocorn/ot7mqseskqdhfoobm1ck86eo/image.png&quot; alt=&quot;image.png-59.6kB&quot; /&gt;

There are various types of user interfaces. bash belongs to the most common category, known as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;character-based user interfaces&lt;/code&gt;.

Remember that the shell itself is not UNIX &lt;strong&gt;just the user interface to it&lt;/strong&gt;. UNIX is one of the first operating systems to make the user interface independent of the operating system.

&lt;h2 id=&quot;history-of-unix-shells&quot;&gt;History of UNIX Shells&lt;/h2&gt;
The first major shell was the &lt;strong&gt;Bourne shell&lt;/strong&gt; (named after its inventor, Steven Bourne); it was included in the first popular version of UNIX, Version 7, starting in 1979.

The first widely used alternative shell was the &lt;strong&gt;C shell&lt;/strong&gt;, or &lt;strong&gt;csh&lt;/strong&gt;. This was written by Bill Joy at the University of California at Berkeley as part of the Berkeley Software Distribution (BSD) version of UNIX that came out a couple of years after Version 7.

In recent years a number of other shells have become popular. The most notable of these is the &lt;strong&gt;Korn shell&lt;/strong&gt;. This shell is a commercial product that incorporates the best features of the Bourne and C shells, plus many features of its own.

The &lt;strong&gt;Bourne Again shell&lt;/strong&gt; (named in punning tribute to Steve Bourne’s shell) was created for use in the GNU project.[2] The GNU project was started by Richard Stallman of the Free Software Foundation (FSF) for the purpose of creating a UNIX-compatible operating system and replacing all of the commercial UNIX utilities with freely distributable ones.

bash, intended to be the standard shell for the GNU system, was officially “born” on Sunday, January 10, 1988. Brian Fox wrote the original versions of bash and readline and continued to improve the shell up until 1993.

You might be able to find the location by typing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whereis bash&lt;/code&gt; (especially if you are using the C shell); if that doesn’t work, try &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whence bash&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;which bash&lt;/code&gt;, or this complex command

&lt;h2 id=&quot;files&quot;&gt;Files&lt;/h2&gt;
Files are the most important types of “things” on any UNIX system. A file can contain any kind of information, and indeed there are different types of files. Three types are by far the most important:

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Regular files:&lt;/strong&gt; Also called text files; these contain readable characters.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Executable files:&lt;/strong&gt; Also called programs, The shell itself is a (non-human-readable) executable file called bash.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Directories:&lt;/strong&gt; These are like folders that contain other files&lt;/li&gt;
&lt;/ul&gt;

&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd -&lt;/code&gt;: changes to whatever directory you were in before the current one.
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -l&lt;/code&gt;’: tells ls to list the file’s owner, size, time of last modification, and other information.
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -a&lt;/code&gt;: lists all files including the hidden files.

Basic wildcards
|Wildcard|Matches|
|:–:|:–:|
|?|Any single character|
|*|Any strings characters|
|[set]|Any character in set|
|[!set]|Any character not in set|
 &lt;strong&gt;pathname expansion&lt;/strong&gt;: it ispossible to use wildcards in the current directory, they can also be used as part of a pathname.
 &lt;strong&gt;Brace Expansion&lt;/strong&gt;:  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo b{ed,olt,ar}s&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo {d..h} &lt;/code&gt; h.

&lt;h2 id=&quot;input-and-output&quot;&gt;Input and Output&lt;/h2&gt;
The UNIX I/O scheme is based on &lt;strong&gt;two dazzlingly simple ideas.&lt;/strong&gt;

&lt;ul&gt;
  &lt;li&gt;UNIX file I/O takes the form of arbitrarily long sequences of characters (bytes).&lt;/li&gt;
  &lt;li&gt;Everything on the system that produces or accepts data is treated as a file. this includes hardware devices like disk drives and terminals.&lt;/li&gt;
&lt;/ul&gt;

&lt;strong&gt;Popular UNIX data filtering utilities&lt;/strong&gt;
|Utility|Purpose|
|:–:|:–:|
|cat|Copy input to output|
|grep|Search for strings in the input|
|sort|Sort lines in the input|
|cut|Extract columns from input|
|sed|Perform editing operations on input|
|tr|Translate characters in the input to other characters|
all of them (and most other UNIX utilities) accept input from standard input if you omit the argument.

&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nice&lt;/code&gt; command, where command can be a complex shell command line with pipes, redirectors, etc., then the command will run at a lower priority.

</description>
        <pubDate>Wed, 03 Jul 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/07/03/Bash-Chapter1-Bash-Basics/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/07/03/Bash-Chapter1-Bash-Basics/</guid>
        
        <category>File</category>
        
        
        <category>Bash</category>
        
      </item>
    
      <item>
        <title>ARTS_Week13</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#algorithm&quot; id=&quot;markdown-toc-algorithm&quot;&gt;Algorithm&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example&quot; id=&quot;markdown-toc-example&quot;&gt;Example&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#solution&quot; id=&quot;markdown-toc-solution&quot;&gt;Solution&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#approach1&quot; id=&quot;markdown-toc-approach1&quot;&gt;Approach1:&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#complexity-analysis&quot; id=&quot;markdown-toc-complexity-analysis&quot;&gt;Complexity analysis&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#review&quot; id=&quot;markdown-toc-review&quot;&gt;Review&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tips&quot; id=&quot;markdown-toc-tips&quot;&gt;Tips&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#share&quot; id=&quot;markdown-toc-share&quot;&gt;Share&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;algorithm&quot;&gt;Algorithm&lt;/h1&gt;
leetcode 344. Reverse String

&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
Write a function that reverses a string. The input string is given as an array of characters char[].

Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

You may assume all the characters consist of printable ascii characters.

&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;
&lt;blockquote&gt;
  Input: [“h”,”e”,”l”,”l”,”o”]
Output: [“o”,”l”,”l”,”e”,”h”]
&lt;/blockquote&gt;

&lt;blockquote&gt;
  Input: [“H”,”a”,”n”,”n”,”a”,”h”]
Output: [“h”,”a”,”n”,”n”,”a”,”H”]
&lt;/blockquote&gt;

&lt;h2 id=&quot;solution&quot;&gt;Solution&lt;/h2&gt;
&lt;h3 id=&quot;approach1&quot;&gt;Approach1:&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;reverseString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;complexity-analysis&quot;&gt;Complexity analysis&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Time complextiy : O(n).&lt;/li&gt;
  &lt;li&gt;Space complexity : O(1).&lt;/li&gt;
&lt;/ul&gt;

Runtime: 1 ms, faster than 100.00% of Java online submissions for Reverse String.
Memory Usage: 47 MB, less than 90.49% of Java online submissions for Reverse String.

&lt;h1 id=&quot;review&quot;&gt;Review&lt;/h1&gt;
&lt;a href=&quot;https://onezero.medium.com/the-libra-masterplan-dc9560e41c87&quot;&gt;Facebook’s Libra Masterplan&lt;/a&gt;

&lt;h1 id=&quot;tips&quot;&gt;Tips&lt;/h1&gt;
&lt;a href=&quot;https://cornprincess.github.io/2019/07/03/Bash-Chapter-1.-bash-Basics/&quot;&gt;Bash Basic&lt;/a&gt;

&lt;h1 id=&quot;share&quot;&gt;Share&lt;/h1&gt;
&lt;a href=&quot;https://medium.com/free-code-camp/follow-these-steps-to-solve-any-dynamic-programming-interview-problem-cc98e508cd0e&quot;&gt;Follow these steps to solve any Dynamic Programming interview problem&lt;/a&gt;

</description>
        <pubDate>Wed, 03 Jul 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/07/03/ARTS-ARTS_Week13/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/07/03/ARTS-ARTS_Week13/</guid>
        
        <category>ARTS</category>
        
        <category>Bash</category>
        
        
        <category>ARTS</category>
        
      </item>
    
      <item>
        <title>ARTS_Week12</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#algorithm&quot; id=&quot;markdown-toc-algorithm&quot;&gt;Algorithm&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example&quot; id=&quot;markdown-toc-example&quot;&gt;Example&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#solution-compare-two-array&quot; id=&quot;markdown-toc-solution-compare-two-array&quot;&gt;Solution: Compare two array&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#approach1-two-stacks&quot; id=&quot;markdown-toc-approach1-two-stacks&quot;&gt;Approach1: Two Stacks&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#complexity-analysis&quot; id=&quot;markdown-toc-complexity-analysis&quot;&gt;Complexity analysis&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#approach2-hashtable&quot; id=&quot;markdown-toc-approach2-hashtable&quot;&gt;Approach2: HashTable&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#complexity-analysis-1&quot; id=&quot;markdown-toc-complexity-analysis-1&quot;&gt;Complexity Analysis&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#review&quot; id=&quot;markdown-toc-review&quot;&gt;Review&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tips&quot; id=&quot;markdown-toc-tips&quot;&gt;Tips&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#share&quot; id=&quot;markdown-toc-share&quot;&gt;Share&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;algorithm&quot;&gt;Algorithm&lt;/h1&gt;
leetcode 242. Valid Anagram

&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
Given two strings s and t , write a function to determine if t is an anagram of s.

&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;
&lt;blockquote&gt;
  Input: s = “anagram”, t = “nagaram”
Output: true
Input: s = “rat”, t = “car”
Output: false
&lt;/blockquote&gt;

&lt;h2 id=&quot;solution-compare-two-array&quot;&gt;Solution: Compare two array&lt;/h2&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;isAnagram&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        
        &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toCharArray&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toCharArray&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;Arrays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;Arrays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Arrays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;equals&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;str1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;str2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;approach1-two-stacks&quot;&gt;Approach1: Two Stacks&lt;/h3&gt;

&lt;h3 id=&quot;complexity-analysis&quot;&gt;Complexity analysis&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;
    Time complexity : O(nlogn). Assume that nn is the length of ss, sorting costs O(nlogn) and comparing two strings costs O(n). Sorting time dominates and the overall time complexity is O(nlogn).
  &lt;/li&gt;
  &lt;li&gt;
    Space complexity : O(1). Space depends on the sorting implementation which, usually, costs O(1) auxiliary space if heapsort is used. Note that in Java, toCharArray() makes a copy of the string so it costs O(n) extra space, but we ignore this for complexity analysis.
  &lt;/li&gt;
&lt;/ul&gt;

Runtime: 7 ms, faster than 32.76% of Java online submissions
Memory Usage: 37.3 MB, less than 76.69% of Java online submissions

&lt;h3 id=&quot;approach2-hashtable&quot;&gt;Approach2: HashTable&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;isAnagram&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;charAt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;sc&quot;&gt;'a'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]++;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;charAt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;sc&quot;&gt;'a'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]--;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;complexity-analysis-1&quot;&gt;Complexity Analysis&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Time complextiy : time complexity is O(n) because accessing the counter table is a constant time operation.&lt;/li&gt;
  &lt;li&gt;Space complexity : Although we do use extra space, the space complexity is O(1) because the table’s size stays constant no matter how large nn is.&lt;/li&gt;
&lt;/ul&gt;

Runtime: 4 ms, faster than 77.25% of Java online submissions for Valid Anagram.
Memory Usage: 36.3 MB, less than 81.82% of Java online submissions for Valid Anagram.

&lt;h1 id=&quot;review&quot;&gt;Review&lt;/h1&gt;
&lt;a href=&quot;https://hackernoon.com/the-future-of-web-development-8da936743d5c&quot;&gt;The Future of Web Development&lt;/a&gt;

&lt;h1 id=&quot;tips&quot;&gt;Tips&lt;/h1&gt;
The notes for requests – python library
The parameters are URL、Method、Headers、Body and so on.
&lt;ul&gt;
  &lt;li&gt;if URL use https，we can add “verify=False” in request method to escape the security verify.&lt;/li&gt;
  &lt;li&gt;Body，the corresponding parameter in requests method is data。Take attention, The  data is assigned a string instead of a dict we can use json.dumps() to convert a dict to string.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;share&quot;&gt;Share&lt;/h1&gt;
This week I watched a video about &lt;a href=&quot;https://content.pivotal.io/springone-platform-2017/test-driven-development-with-spring-boot-sannidhi-jalukar-madhura-bhave&quot;&gt;Test Driven Development with Spring Boot&lt;/a&gt;, the video is friendly to new development.

</description>
        <pubDate>Mon, 24 Jun 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/06/24/ARTS-ARTS_Week12/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/06/24/ARTS-ARTS_Week12/</guid>
        
        <category>ARTS</category>
        
        
        <category>ARTS</category>
        
      </item>
    
      <item>
        <title>ARTS_Week11</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#algorithm&quot; id=&quot;markdown-toc-algorithm&quot;&gt;Algorithm&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example&quot; id=&quot;markdown-toc-example&quot;&gt;Example&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#solution&quot; id=&quot;markdown-toc-solution&quot;&gt;Solution&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#approach1-two-stacks&quot; id=&quot;markdown-toc-approach1-two-stacks&quot;&gt;Approach1: Two Stacks&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#complexity-analysis&quot; id=&quot;markdown-toc-complexity-analysis&quot;&gt;Complexity analysis&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#approach2-two-stacks&quot; id=&quot;markdown-toc-approach2-two-stacks&quot;&gt;Approach2: Two Stacks&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#complexity-analysis-1&quot; id=&quot;markdown-toc-complexity-analysis-1&quot;&gt;Complexity Analysis&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#review&quot; id=&quot;markdown-toc-review&quot;&gt;Review&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tips&quot; id=&quot;markdown-toc-tips&quot;&gt;Tips&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#share&quot; id=&quot;markdown-toc-share&quot;&gt;Share&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;algorithm&quot;&gt;Algorithm&lt;/h1&gt;
leetcode 232. Implement Queue using Stacks

&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
Implement the following operations of a queue using stacks.

&lt;ul&gt;
  &lt;li&gt;push(x) – Push element x to the back of queue.&lt;/li&gt;
  &lt;li&gt;pop() – Removes the element from in front of queue.&lt;/li&gt;
  &lt;li&gt;peek() – Get the front element.&lt;/li&gt;
  &lt;li&gt;empty() – Return whether the queue is empty.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;
&lt;blockquote&gt;
  MyQueue queue = new MyQueue();

  queue.push(1);
queue.push(2);&lt;br /&gt;
queue.peek();  // returns 1
queue.pop();   // returns 1
queue.empty(); // returns false
&lt;/blockquote&gt;

&lt;h2 id=&quot;solution&quot;&gt;Solution&lt;/h2&gt;
&lt;h3 id=&quot;approach1-two-stacks&quot;&gt;Approach1: Two Stacks&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyQueue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;front&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Initialize your data structure here. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;MyQueue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Push element x to the back of queue. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;front&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Removes the element from in front of queue and returns that element. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;front&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;peek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Get the front element. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;peek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;front&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Returns whether the queue is empty. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;complexity-analysis&quot;&gt;Complexity analysis&lt;/h3&gt;
&lt;strong&gt;push():&lt;/strong&gt;
Time complextiy : O(N). 
Space complexity : O(N).
&lt;strong&gt;pop(), empty(), peek():&lt;/strong&gt;
Time complextiy : O(1). 
Space complexity : O(1).

Runtime: 45 ms, faster than 19.26%
Memory Usage: 34.3 MB, less than 45.05%

&lt;h3 id=&quot;approach2-two-stacks&quot;&gt;Approach2: Two Stacks&lt;/h3&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyQueue&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;front&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Initialize your data structure here. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;MyQueue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Push element x to the back of queue. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;front&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Removes the element from in front of queue and returns that element. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Get the front element. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;peek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;peek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;front&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    
    &lt;span class=&quot;cm&quot;&gt;/** Returns whether the queue is empty. */&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;complexity-analysis-1&quot;&gt;Complexity Analysis&lt;/h2&gt;
&lt;strong&gt;push():&lt;/strong&gt;
Time complextiy : O(1). 
Space complexity : O(N).
&lt;strong&gt;empty(), peek():&lt;/strong&gt;
Time complextiy : O(1). 
Space complexity : O(1).
&lt;strong&gt;pop()&lt;/strong&gt;:
Time complextiy : Amortized O(1), Worst-case O(n). 
Space complexity : O(1).

Runtime: 1 ms, faster than 41.71%
Memory Usage: 36.4 MB, less than 57.64%

&lt;h1 id=&quot;review&quot;&gt;Review&lt;/h1&gt;
This week the company has taught the concept of the microservice, I read this article to see how the main login function works. 
&lt;a href=&quot;https://medium.com/technology-learning/how-we-solved-authentication-and-authorization-in-our-microservice-architecture-994539d1b6e6&quot;&gt;How We Solved Authentication and Authorization in Our Microservice Architecture&lt;/a&gt;

&lt;h1 id=&quot;tips&quot;&gt;Tips&lt;/h1&gt;
I want to share some skills about docker, this is the senior developer told me.
&lt;ol&gt;
  &lt;li&gt;use crtl + P and crtl Q to exit the docker container instead of using exit(), because it may casue the docker container down.&lt;/li&gt;
  &lt;li&gt;use docker exec -it [containerId] sh instead bash, beacause the docker not support bash.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;share&quot;&gt;Share&lt;/h1&gt;
I read &lt;a href=&quot;https://medium.com/taking-note/learning-from-the-feynman-technique-5373014ad230&quot;&gt;Learning From the Feynman Technique&lt;/a&gt;this week and want to share it.
&lt;blockquote&gt;
  Richard Feynman (1918–1988), an author, graphic novel hero, intellectual, philosopher, physicist, and No Ordinary Genius is considered to be one of the most important physicists of all time.
&lt;/blockquote&gt;

The Feynman technique for teaching and communication is a mental model (a breakdown of his personal thought process) to convey information using concise thoughts and simple language.

&lt;ol&gt;
  &lt;li&gt;
    Identify the subject
Write down everything you know about the topic. Each time you run into new sources of information, add them to the note.
  &lt;/li&gt;
  &lt;li&gt;
    Teach it to a child
If you can teach a concept to a child, you’re way ahead of the game.
  &lt;/li&gt;
  &lt;li&gt;
    Identify your knowledge gaps
This is the point where the real learning happens. What are you missing? What don’t you know?
  &lt;/li&gt;
  &lt;li&gt;
    Organize + simplify + Tell a story
Start to tell your story. Piece together your notes and begin to spin a tale using concise explanations. Bring the most vital pieces of your knowledge about the topic together.
  &lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Tue, 18 Jun 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/06/18/ARTS-ARTS_Week11/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/06/18/ARTS-ARTS_Week11/</guid>
        
        <category>ARTS</category>
        
        <category>Python</category>
        
        <category>Feynman</category>
        
        
        <category>ARTS</category>
        
      </item>
    
      <item>
        <title>ARTS_Week10</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#algorithm&quot; id=&quot;markdown-toc-algorithm&quot;&gt;Algorithm&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example&quot; id=&quot;markdown-toc-example&quot;&gt;Example&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#solution&quot; id=&quot;markdown-toc-solution&quot;&gt;Solution&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#approach1-brute-force&quot; id=&quot;markdown-toc-approach1-brute-force&quot;&gt;Approach1: Brute Force&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#complexity-analysis&quot; id=&quot;markdown-toc-complexity-analysis&quot;&gt;Complexity analysis&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#review&quot; id=&quot;markdown-toc-review&quot;&gt;Review&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tips&quot; id=&quot;markdown-toc-tips&quot;&gt;Tips&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#share&quot; id=&quot;markdown-toc-share&quot;&gt;Share&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;algorithm&quot;&gt;Algorithm&lt;/h1&gt;
leetcode 234. Palindrome Linked List

&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
Given a singly linked list, determine if it is a palindrome.

&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;
&lt;blockquote&gt;
  Input: 1-&amp;gt;2
Output: false
&lt;/blockquote&gt;

&lt;blockquote&gt;
  Input: 1-&amp;gt;2-&amp;gt;2-&amp;gt;1 
Output: true
&lt;/blockquote&gt;

&lt;h2 id=&quot;solution&quot;&gt;Solution&lt;/h2&gt;
&lt;h3 id=&quot;approach1-brute-force&quot;&gt;Approach1: Brute Force&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;isPalindrome&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ListNode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;ListNode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;ListNode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        
        &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;   
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;slow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ListNode&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ListNode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;ListNode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;ListNode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;complexity-analysis&quot;&gt;Complexity analysis&lt;/h3&gt;
Time complextiy : O(N). Assume that n is the length of LinkedList.
Space complexity : O(1).

Runtime: 1 ms, faster than 97.34% % 
Memory Usage: 40.9 MB, less than 91.63%

&lt;h1 id=&quot;review&quot;&gt;Review&lt;/h1&gt;
I am learning web development now, and I know agentzh is the creator of &lt;a href=&quot;https://openresty.org/en/getting-started.html&quot;&gt;openresty&lt;/a&gt;, I browsed the offical website and planed to try the tutorial next week.

&lt;h1 id=&quot;tips&quot;&gt;Tips&lt;/h1&gt;
When we use the computer in company, it is a good custom to configure the  mirror and proxy to download the dependencies quickly.

&lt;h1 id=&quot;share&quot;&gt;Share&lt;/h1&gt;
This week I read an article about the basic architecture concepts that is valuable for  knew web developer beginner.

The article is &lt;a href=&quot;https://engineering.videoblocks.com/web-architecture-101-a3224e126947&quot;&gt;Web Architecture 101&lt;/a&gt;

</description>
        <pubDate>Tue, 11 Jun 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/06/11/ARTS-ARTS_Week10/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/06/11/ARTS-ARTS_Week10/</guid>
        
        <category>ARTS</category>
        
        <category>Python</category>
        
        
        <category>ARTS</category>
        
      </item>
    
      <item>
        <title>ARTS_Week9</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#algorithm&quot; id=&quot;markdown-toc-algorithm&quot;&gt;Algorithm&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example&quot; id=&quot;markdown-toc-example&quot;&gt;Example&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#solution&quot; id=&quot;markdown-toc-solution&quot;&gt;Solution&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#approach1-brute-force&quot; id=&quot;markdown-toc-approach1-brute-force&quot;&gt;Approach1: Brute Force&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#complexity-analysis&quot; id=&quot;markdown-toc-complexity-analysis&quot;&gt;Complexity analysis&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#review&quot; id=&quot;markdown-toc-review&quot;&gt;Review&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tips&quot; id=&quot;markdown-toc-tips&quot;&gt;Tips&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#share&quot; id=&quot;markdown-toc-share&quot;&gt;Share&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#always-think-ahead&quot; id=&quot;markdown-toc-always-think-ahead&quot;&gt;Always think ahead&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#theres-more-than-one-answer&quot; id=&quot;markdown-toc-theres-more-than-one-answer&quot;&gt;There’s more than one answer&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#oop-is-not-dead&quot; id=&quot;markdown-toc-oop-is-not-dead&quot;&gt;OOP is not dead&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#craft-your-resume&quot; id=&quot;markdown-toc-craft-your-resume&quot;&gt;Craft your resume&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#communicate-early-and-communicate-often&quot; id=&quot;markdown-toc-communicate-early-and-communicate-often&quot;&gt;Communicate early and communicate often&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#reference&quot; id=&quot;markdown-toc-reference&quot;&gt;Reference&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;algorithm&quot;&gt;Algorithm&lt;/h1&gt;
leetcode 53. Maximum Subarray

&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;
&lt;blockquote&gt;
  Input: [-2,1,-3,4,-1,2,1,-5,4],
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
&lt;/blockquote&gt;

&lt;h2 id=&quot;solution&quot;&gt;Solution&lt;/h2&gt;
&lt;h3 id=&quot;approach1-brute-force&quot;&gt;Approach1: Brute Force&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;maxSubArray&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;MIN_VALUE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
            
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;complexity-analysis&quot;&gt;Complexity analysis&lt;/h3&gt;
Time complextiy : O(N). Assume that n is the length of nums.
Space complexity : O(1).

Runtime: 1 ms, faster than 94.43% 
Memory Usage: 38.7 MB, less than 45.76%

&lt;h1 id=&quot;review&quot;&gt;Review&lt;/h1&gt;
I am learning web development now, and I know agentzh is the creator of &lt;a href=&quot;https://openresty.org/en/getting-started.html&quot;&gt;openresty&lt;/a&gt;, I browsed the offical website and planed to try the tutorial next week.

&lt;h1 id=&quot;tips&quot;&gt;Tips&lt;/h1&gt;
This week is a little busy, I just recommend a note app: &lt;a href=&quot;https://www.yinxiang.com/?referer=en&quot;&gt;EverNote&lt;/a&gt;

&lt;h1 id=&quot;share&quot;&gt;Share&lt;/h1&gt;
This week I will share some skills during interview, I think they are practial skills beacuse everyone wants to achieve dream offer.

&lt;h2 id=&quot;always-think-ahead&quot;&gt;Always think ahead&lt;/h2&gt;
Often, you’ll hear an interviewer ask this: “OK, I think that looks good. Now, how would you improve this code?” &lt;strong&gt;This is a killer question.&lt;/strong&gt; Being able to come up with a working solution is the bare minimum to be considered for the position. These questions are basic competency tests. What separates the good candidates from great is the ability to think beyond what’s required.

Think about edge cases, scaling issues, problem areas. Always think one step ahead. If you’re using a recursive approach, what would happen if you have a large data set? If you’re using a hashing algorithm, how do you handle collisions? How likely is that to happen, and what’s the worst case scenario?

&lt;h2 id=&quot;theres-more-than-one-answer&quot;&gt;There’s more than one answer&lt;/h2&gt;
From an interviewer perspective, I’m not looking to check if you know what the right answer is. Yes, it is important that you can write a working solution, but it’s not the only thing.

More than that, I’m looking for how smart this person is, how the solution is derived, and what other creative solutions this person might be thinking about.

&lt;h2 id=&quot;oop-is-not-dead&quot;&gt;OOP is not dead&lt;/h2&gt;
Many candidates jump head-first into a programming problem without putting further thought into simplifying the code. I used to be in this bunch and, admittedly, I still do it sometimes.

&lt;h2 id=&quot;craft-your-resume&quot;&gt;Craft your resume&lt;/h2&gt;
If you’re starting out on your job search, then the very first thing you should do is prepare a great resume. That’s the number one thing that is often overlooked by job seekers and, arguably, is the lowest hanging fruit.

&lt;h2 id=&quot;communicate-early-and-communicate-often&quot;&gt;Communicate early and communicate often&lt;/h2&gt;
Communicate as often as you need. I tried to communicate early and often. Whenever there was an issue, I would raise it with the interviewer and let them know. It helped me determine if I was heading in the right direction, and course-correct if I was not.

&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;
&lt;a href=&quot;https://medium.com/free-code-camp/the-most-important-things-you-need-to-know-for-a-programming-interview-3429ac2454b&quot;&gt;5 things you need to know in a programming interview&lt;/a&gt;

</description>
        <pubDate>Mon, 03 Jun 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/06/03/ARTS-ARTS_Week9/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/06/03/ARTS-ARTS_Week9/</guid>
        
        <category>ARTS</category>
        
        <category>Python</category>
        
        
        <category>ARTS</category>
        
      </item>
    
      <item>
        <title>ARTS_Week8</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#algorithm&quot; id=&quot;markdown-toc-algorithm&quot;&gt;Algorithm&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example&quot; id=&quot;markdown-toc-example&quot;&gt;Example&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example-1&quot; id=&quot;markdown-toc-example-1&quot;&gt;Example&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#note&quot; id=&quot;markdown-toc-note&quot;&gt;Note&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#solution&quot; id=&quot;markdown-toc-solution&quot;&gt;Solution&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#approach1-brute-force&quot; id=&quot;markdown-toc-approach1-brute-force&quot;&gt;Approach1: Brute Force&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#complexity-analysis&quot; id=&quot;markdown-toc-complexity-analysis&quot;&gt;Complexity analysis&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#approach2-using-extra-array&quot; id=&quot;markdown-toc-approach2-using-extra-array&quot;&gt;Approach2: Using Extra Array&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#complexity-analysis-1&quot; id=&quot;markdown-toc-complexity-analysis-1&quot;&gt;Complexity Analysis&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#approach3using-cyclic-replacements&quot; id=&quot;markdown-toc-approach3using-cyclic-replacements&quot;&gt;Approach3:Using Cyclic Replacements&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#complexity-analysis-2&quot; id=&quot;markdown-toc-complexity-analysis-2&quot;&gt;Complexity Analysis&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#review&quot; id=&quot;markdown-toc-review&quot;&gt;Review&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tips&quot; id=&quot;markdown-toc-tips&quot;&gt;Tips&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;algorithm&quot;&gt;Algorithm&lt;/h1&gt;
leetcode 189. Rotate Array

&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
Given an array, rotate the array to the right by k steps, where k is non-negative.

&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;
&lt;blockquote&gt;
  Input: [1,2,3,4,5,6,7] and k = 3
Output: [5,6,7,1,2,3,4]
Explanation:
rotate 1 steps to the right: [7,1,2,3,4,5,6]
rotate 2 steps to the right: [6,7,1,2,3,4,5]
rotate 3 steps to the right: [5,6,7,1,2,3,4]
&lt;/blockquote&gt;

&lt;h2 id=&quot;example-1&quot;&gt;Example&lt;/h2&gt;
&lt;blockquote&gt;
  Input: [-1,-100,3,99] and k = 2
Output: [3,99,-1,-100]
Explanation: 
rotate 1 steps to the right: [99,-1,-100,3]
rotate 2 steps to the right: [3,99,-1,-100]
&lt;/blockquote&gt;

&lt;h2 id=&quot;note&quot;&gt;Note&lt;/h2&gt;
&lt;blockquote&gt;
  Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.
Could you do it &lt;strong&gt;in-place&lt;/strong&gt; with O(1) extra space?
&lt;/blockquote&gt;

&lt;h2 id=&quot;solution&quot;&gt;Solution&lt;/h2&gt;
&lt;h3 id=&quot;approach1-brute-force&quot;&gt;Approach1: Brute Force&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;previous&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;previous&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;previous&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;previous&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;complexity-analysis&quot;&gt;Complexity analysis&lt;/h3&gt;
Time complextiy : O(N*k). Assume that n is the length of nums, and k is the number of roatate tiems.
Space complexity : O(1).

Runtime: 83 ms, faster than 19.76% 
Memory Usage: 37.2 MB, less than 57.19%

&lt;h3 id=&quot;approach2-using-extra-array&quot;&gt;Approach2: Using Extra Array&lt;/h3&gt;
We use an extra array in which we place every element of the array at its correct position.

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;complexity-analysis-1&quot;&gt;Complexity Analysis&lt;/h2&gt;
Time complexity : O(n). One pass is used to put the numbers in the new array. And another pass to copy the new array to the original one.
Space complexity : O(n). Another array of the same size is used.

Runtime: 1 ms, faster than 41.71%
Memory Usage: 36.4 MB, less than 57.64%

&lt;h3 id=&quot;approach3using-cyclic-replacements&quot;&gt;Approach3:Using Cyclic Replacements&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;current&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;nums&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;prev&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;complexity-analysis-2&quot;&gt;Complexity Analysis&lt;/h3&gt;
Time complexity : O(n)O(n). Only one pass is used.
Space complexity : O(1)O(1). Constant extra space is used.

Runtime: 0 ms, faster than 100.00% 
Memory Usage: 36.3 MB, less than 58.01%

&lt;h1 id=&quot;review&quot;&gt;Review&lt;/h1&gt;
I am learning web development now, and I know agentzh is the creator of &lt;a href=&quot;https://openresty.org/en/getting-started.html&quot;&gt;openresty&lt;/a&gt;, I browsed the offical website and planed to try the tutorial next week.

&lt;h1 id=&quot;tips&quot;&gt;Tips&lt;/h1&gt;
I am learning python rege now, the following are some trips I have met with.

&lt;ul&gt;
  &lt;li&gt;match with zero and more: *&lt;/li&gt;
  &lt;li&gt;match with one and more: +&lt;/li&gt;
  &lt;li&gt;match specific repetitions with curly brackets
```python
    &lt;blockquote&gt;
      &lt;blockquote&gt;
        &lt;blockquote&gt;
          greedyHaRegex = re.compile(r’(Ha){3,5}’)
mo1 = greedyHaRegex.search(‘HaHaHaHaHa’)
mo1.group()
‘HaHaHaHaHa’
        &lt;/blockquote&gt;
      &lt;/blockquote&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;blockquote&gt;
    &lt;blockquote&gt;
      nongreedyHaRegex = re.compile(r’(Ha){3,5}?’)
mo2 = nongreedyHaRegex.search(‘HaHaHaHaHa’)
mo2.group()
‘HaHaHa’
```
Note that the question mark can have two meanings in regular expressions: declaring a nongreedy match or flagging an optional group. These meanings are entirely unrelated.
    &lt;/blockquote&gt;
  &lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;findAll() method
```python
    &lt;blockquote&gt;
      &lt;blockquote&gt;
        &lt;blockquote&gt;
          phoneNumRegex = re.compile(r’\d\d\d-\d\d\d-\d\d\d\d’) # has no groups
phoneNumRegex.findall(‘Cell: 415-555-9999 Work: 212-555-0000’)
[‘415-555-9999’, ‘212-555-0000’]
        &lt;/blockquote&gt;
      &lt;/blockquote&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;blockquote&gt;
    &lt;blockquote&gt;
      phoneNumRegex = re.compile(r’(\d\d\d)-(\d\d\d)-(\d\d\d\d)’) # has groups
phoneNumRegex.findall(‘Cell: 415-555-9999 Work: 212-555-0000’)
[(‘415’, ‘555’, ‘9999’), (‘212’, ‘555’, ‘0000’)]
```
    &lt;/blockquote&gt;
  &lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;
    To summarize what the findall() method returns, remember the following:
  &lt;/li&gt;
  &lt;li&gt;
    When called on a regex with no groups, such as \d\d\d-\d\d\d-\d\d\d\d, the method findall() returns a list of string matches, such as [‘415-555-9999’, ‘212-555-0000’].
  &lt;/li&gt;
  &lt;li&gt;
    When called on a regex that has groups, such as (\d\d\d)-(\d\d\d)-(\d\ d\d\d), the method findall() returns a list of tuples of strings (one string for each group), such as [(‘415’, ‘555’, ‘9999’), (‘212’, ‘555’, ‘0000’)].
  &lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Sat, 25 May 2019 15:50:12 +0000</pubDate>
        <link>https://CornPrincess.github.io/2019/05/25/ARTS-ARTS_Week8/</link>
        <guid isPermaLink="true">https://CornPrincess.github.io/2019/05/25/ARTS-ARTS_Week8/</guid>
        
        <category>ARTS</category>
        
        <category>Python</category>
        
        <category>openresty</category>
        
        
        <category>ARTS</category>
        
      </item>
    
  </channel>
</rss>
