Articles

Technical articles and tutorials for developers

学习得到了什么
Quick Notes

学习得到了什么

有人问:“你总是在学习,通过学习,最终得到了什么?” 答:“什么都没有得到。” 他再问:“那您还学习做什么呢?” 微笑:“不过我可以告诉你我失去的东西。我失去愤怒、纠结、狭隘、挑剔和指责、悲观和沮丧;失去了肤浅、短视;失去了无知、干扰和障碍。” 学习的真谛不是做加法,而是做减法;提升的目的不是为了得到,而是放弃迷妄,剔除怒恨怨恼烦和贪嗔痴慢疑!

chris Jan 07, 2021
QuickSort
Algorithm

QuickSort

Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot. There are many different versions of quickSort that pick pivot in different ways.

  1. Always pick first element as pivot.
  2. Always pick last element as pivot (implemented below)
  3. Pick a random element as pivot.
  4. Pick median as pivot.

The key process in quickSort is partition(). Target of partitions is, given an array and an element x of array as pivot, put x at its correct position in sorted array and put all smaller elements (smaller than x) before x, and put all greater elements (greater than x) after x. All this should be done in linear time.

chris Dec 30, 2020
Set in C++ Standard Template Library (STL)
C++

Set in C++ Standard Template Library (STL)

Sets are a type of associative containers in which each element has to be unique, because the value of the element identifies it. The value of the element cannot be modified once it is added to the set, though it is possible to remove and add the modified value of that element. Some basic functions associated with Set:

  • begin() – Returns an iterator to the first element in the set.
  • end() – Returns an iterator to the theoretical element that follows last element in the set.
  • size() – Returns the number of elements in the set.
  • max_size() – Returns the maximum number of elements that the set can hold.
  • empty() – Returns whether the set is empty.
chris Dec 30, 2020
低情商的人讲道理,高情商的人谈感受
Miscellaneous reading

低情商的人讲道理,高情商的人谈感受

要说最让人讨厌的低情商的沟通方式,讲道理一定位居前列。

前两天在工作中遇到了一个难搞的合作方,把我气得快要崩盘了,一下班立马约了个朋友,想跟她吐槽一下。

结果刚坐下来点了杯奶茶,我开始吐槽不到2分钟,朋友就打断了我,语重心长地说了一大段话,大概的意思是:

在职场上你应该更加专业一点,不要那么情绪化;越是面对这样的人,你就越不能生气,他就得逞了;你要硬气一点,不要让他觉得女人在职场那么好欺负……

听完这段话后,我吸了一大口冰奶茶,什么都不想再说了。

memory Dec 27, 2020
天赋自然重要,勤奋,立志更重要
Reading

天赋自然重要,勤奋,立志更重要

摘自:《曾国藩传

有这样一个故事说明曾国藩读书的勤奋。

一天,曾国藩在家背书,可有一篇文章就是背不下来。这时有 个贼正潜伏在他的屋檐下,准备等他背完睡觉后动手行窃。可曾国藩因一直背不下来,就不去睡觉。贼等不及了,跳起来大怒道:“你这个笨蛋,背了这么多遍还背不下来,我都听会了!”说完,那个贼果然背诵一遍,然后扬长而去。 贼虽然比曾国藩记忆力好,但他只配做贼,而曾国藩虽然当时没有背下来文章,但后来却成了杰出人物。

chris Dec 26, 2020
什么样的勇气是假的
Reading

什么样的勇气是假的

摘自:[逻辑思维]

话说战国的时候有一桩悬案。荆轲刺秦王的时候,需要带一个助手。找来找去,找到了燕国的秦舞阳。

为啥找他呢?因为据说他12岁当街杀人,满街的人都不敢看他一眼,你想,这是多大的杀气?

可是,等到荆轲带着秦舞阳见到秦王的时候,秦舞阳“色变振恐”,吓尿裤子了。奇怪,原来挺有勇气的一个人,怎么事到临头就怂了呢?

chris Dec 26, 2020