简易优先队列(heap) js 版

这个优先队列使用数组存储。下面的代码是一个最大(不管是现实世界还是计算机的世界,什么是大什么是小,都是可以定义的)堆的实现。

基于堆的优先队列,出队,入队都是 logn 级别的时间复杂度。

提供 heapify 的实现。

继续阅读“简易优先队列(heap) js 版”

宝回老家了

2025-06-30

菜鸟面试官的一点思考

2025-06-26

“The boolean trap” is just one example of how seemingly simple modeling decisions can have unexpected consequences as systems grow. While booleans are perfect for their intended purpose – representing true/false technical states – they often fall short when applied to a domain. By choosing enums and enum sets we create code that is better prepared for the “real world”‘ of the problem domain.

Sometimes it’s better to rethink how we represent the state instead of blindly adding another boolean flag.

https://katafrakt.me/2024/11/09/booleans-are-a-trap

乱语:这位老哥说在领域模型内,使用布尔值不是很好,得用枚举或者是状态机。

继续阅读“宝回老家了”

收到起诉状

2025-05-31

A proof of concept (POC or PoC), also known as proof of principle, is an inchoate realization of a certain idea or method in order to demonstrate its feasibility[1] or viability.[2]

A proof of concept is usually small and may or may not be complete, but aims to demonstrate in principle that the concept has practical potential without needing to fully develop it.

乱语:简单翻译来看,就是对概念的证明。

2025-05-30

流转知何世,江山尚此亭。
登临皆旷士,丧乱有遗经。
已识乾坤大,犹怜草木青。
长空送鸟印,留幻与人灵。

【词语力量354】犹怜草木青。“已识乾坤大,犹怜草木青”,即便是经历世事沉浮、阅尽人间沧桑,当俯下身子看到草木生发……

草木之枯荣于我之人生有何增益?春秋之轮换于我之富贵能添几何?生活之重担已令人不堪负,又有何心力去关心草木是否变青、春花是否再发?

继续阅读“收到起诉状”

想了一个面试题:树的过滤

给候选人做的题,应该好理解,如果讲半天题目,对方都不理解,我都怀疑是不是我的表达能力不行。题目足够简单,我讲解题目也省事,对方不理解或者不能做出来,则淘汰就好,我心里也没有负担。

继续阅读“想了一个面试题:树的过滤”

记一次花xxx块钱通过黄牛坐高铁

通过这次坐高铁,我觉得自己很机械,不会变通,黄牛出售的是一种思路,一种很普通简单的思路,感觉被收了智商税,书读了那么多年,反而像是被教育害了。社会让我们做一个守规矩的人,回头看,要懂得逾越规矩时,人已经老了。

人要有创新思维,打破常规。创业赚钱也是这个道理,工作中想要轻松的工作也是这个道理。

继续阅读“记一次花xxx块钱通过黄牛坐高铁”

附耳切除术

2025-03-31

英文版的一些力扣题解不能看,要开会员,但是中文版,可以免费看。

https://leetcode.cn/problems/climbing-stairs/solutions/286022/pa-lou-ti-by-leetcode-solution

2025-03-29

可视化寻路算法,来自宾夕法尼亚大学数学专业的大佬

Welcome to Pathfinding Visualizer! I built this application because I was fascinated by pathfinding algorithms, and I wanted to visualize them in action. I hope that you enjoy playing around with this visualization tool just as much as I enjoyed building it.

https://clementmihailescu.github.io/Pathfinding-Visualizer/

继续阅读“附耳切除术”

开始分居

2025-02-27

15 【每天认识一架飞机,今天是空客A320 – 华夏飞滴 | 小红书 – 你的生活指南】 😆 Bwwy4AFnTT2CiKA 😆

https://www.xiaohongshu.com/discovery/item/66b1be7f000000001e01b0df?source=webshare&xhsshare=pc_web&xsec_token=AB-qw1hyDAsVjCJNdfbU5mkZGFSxUGNdGRWsVneXtc51M=&xsec_source=pc_share

2019年11月,A320的订单数目(15,193架)超越737客机(15,136架),成为航空历史上销量最高的客机。不过截至2021年4月为止,737客机的实际交付量(10,681架)仍领先于A320(9,832架)。A320是现役数量最多的客机。

继续阅读“开始分居”

工作中的一个问题之二

有一个二维数组如下:

let arr = [["a0", "a1"], ["a1", "a2"], ["a3"]];

我们看到 a1 这个元素在数组的第 0 项和第 1 项都存在了,我们需要将其合并成一项:

// 需要转化成 [["a0", "a1", "a2"], ["a3"]]

同理,针对一个任意项的二维数组,只要其中某单个元素重复了,就应该合并进同一个数组里,减少这个二维数组的个数。那么怎么实现这个呢?

继续阅读“工作中的一个问题之二”