Problem Description

After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, the security system for these houses remain the same as for those in the previous street.

Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

阅读全文 »

问题

使用 Hexo 部署博客到 Github Pages 时经常会遇到文件夹大小写问题导致的 404问题。

譬如 Hexo 生成了一个 Hackerrank in JS Category文件夹,但是我后来把它改成了 Hackerrank In JS,即 in 的首字母大写了。Hexo会生成正确,但部署到 Github 上却老是不正确。

原因

git 默认忽略文件名大小写,所以即使文件夹大小写变更,git 也检测不到。

阅读全文 »

Problem Description

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

阅读全文 »

前言

上周参加了学校的 Career Fair,想锻炼下面试技巧和口语能力,为下学期找暑期实习做点准备。那天整条路都是熙熙攘攘的面试官和学生,Facebook、Amazon、Microsoft、eBay 这些大公司尤其火爆,有的人排了几个小时才面试上。

因为我刚来 USC 两个月,实力不够,而且大公司又有冷冻期(一次没有录上半年内不再面试),所以我也没敢投大公司,挑了几个看起来不错的小公司试试水。一共投了五个,拿到 Percolate 和 Paypal 两家的 Coding Challenge,还有一家 Demand Media 说是非常喜欢我,之后会打电话让我去 onsite interview(为啥现在还没打电话!)。

这道题是 Percolate 的题,名字叫 Funky Rolodex(复杂的关系网) 并没有考算法,而是非常贴近实际需求,处理文本文件,筛选出正确的数据解析并输出成JSON格式。虽然并不难,但是需要注意的小细节不少,譬如输出结果要按照相应地缩进,要对数据按照 Lastname 和 Firstname 排序。我之前没有注意到排序这一点,导致后来重构了一些代码,而且对我来说,排序这里是最难的(后面会解释)。

总体来说这是一道非常好的非算法题,考到了JSON,正则表达式,面向对象编程,字符串比较等等,而且这道题非常考察细心程度。

阅读全文 »

Problem Description

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

For example:

Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it.

阅读全文 »

前言

今天早上因为罪恶感奋发图强,早早起来开始背单词。背之前想先听一下WordList 3的单词音频,所以用手机对着红宝书WordList上的二维码扫了一下,进入网页听录音(新东方真是与时俱进呀!都用上二维码了!!)。

听了一会,突发奇想,何不把所有WordList的音频都下下来装在手机里呢,这样随时都可以听!于是开始笨拙的把微信里的网页链接分享到电脑上,然后用浏览器一个一个的下载,下了几个感觉不对劲。。。太麻烦了,这种重复性的工作干嘛要自己做!!交给计算机就好了嘛!

so,我写了个nodejs程序批量的下载,不到1分钟,42个list的录音就都进入了我的硬盘。 ; )

首先是github 项目地址,取名为 getGreWordListTapes ~

下面我说说制作过程

阅读全文 »

connect简介

Connect is a middleware framework for node.

Connect 是 nodejs 的中间件框架。何为中间件?中间件就是用户请求和返回结果之间的一个又一个筛选工具。正如 @Luics 所说“如果把一个http处理过程比作是污水处理,中间件就像是一层层的过滤网。”

中间件能在请求用户请求处理之前,进行一些预处理,而在返回结果之前,又进行一些返回之前的处理。非常类似于洋葱模型,一层一层的进入,又一层一层的退出。

阅读全文 »

今天入职,耶!

公司安排的酒店在西湖区,离阿里大本营西溪园区10公里左右。好在支付宝大厦在西湖区天目山路,离酒店不远,支付宝和西溪园区之间还有公司的穿梭巴士。所以和小伙伴们约好了早上去坐7:40的穿梭巴士。

室友6点刚过就爬起床了,洗漱声把我也吵醒了。无奈起床洗漱,洗漱完才6:30。不幸福 =_=。

恰逢杭州下起了小雨,折腾了一会,总算到了支付宝大厦。坐上巴士启程。半小时左右就到了,先入职了的小伙伴领着去食堂吃了顿不错的早餐:甜!豆腐脑+贵族食品茶叶蛋+小资情调小蛋糕~

阅读全文 »