作者归档:在线疯狂

RSS feed of 在线疯狂

[LeetCode]Reorder List

题目描述:

Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…

You must do this in-place without altering the nodes' values.

For example,
Given {1,2,3,4}, reorder it to {1,4,2,3}.

题目大意:

给定一个单链表L:L0→L1→…→Ln-1→Ln
重新将其排序为 ...

继续阅读

[LeetCode]Binary Tree Preorder Traversal

题目描述:

Given a binary tree, return the preorder traversal of its nodes' values.

For example:

Given binary tree {1,#,2,3},

   1
    \
     2
    /
   3

return [1,2,3].

题目大意:

给定一棵二叉树,返回节点值的先序遍历结果(尽量使用非递归算法)。

解题思路:

使用数据结构栈(Stack)

先序遍历非递归算法的伪代码如下(摘自Wikipedia):

iterativePreorder(node)
  parentStack ...

继续阅读

[TopCoder]SRM 647 Div2 Travelling Salesman Easy

题目描述:

You are a traveling salesman. You have already heard a lot about how hard the problems of a traveling salesman can be. Luckily, the one you currently have seems easier.

There are M cities where you can sell products ...

继续阅读

[LeetCode]Department Top Three Salaries

题目描述:

The Employee table holds all employees. Every employee has an Id, and there is also a column for the department Id.

+----+-------+--------+--------------+
| Id | Name  | Salary | DepartmentId |
+----+-------+--------+--------------+
| 1  | Joe   | 70000  | 1            |
| 2  | Henry | 80000  | 2            |
| 3  | Sam   | 60000  | 2            |
| 4  | Max ...

继续阅读

深入了解Alexa排名

什么是Alexa排名?

Alexa排名反映了一个网站的受欢迎程度。最受欢迎的网站的Alexa排名为1。如果Alexa的排名为100,000,则说明这个网站是全球第100,000受欢迎的网站。通常人们提到的Alexa排名指的是全球排名,此外Alexa还有各个国家的网站排名。

怎样获取某个特定网站的Alexa排名?

你可以安装浏览器扩展(官方工具栏 或者 Chrome , Firefox工具栏),然后当你浏览网站时就可以看到对应网站的Alexa排名了。

或者也可以直接访问http://www.alexa.com,在搜索框中键入网站域名进行查询。

Alexa排名是怎样计算的?

如前所述,许多用户安装了Alexa的浏览器工具栏或者扩展,它们会将用户访问网站的信息发送给alexa.com。你可能很惊讶,但有数百万的人在这样做。Alexa跟踪这些人最近3个月访问的网站数据,并据此对网站进行排名。

Alexa的创始人是谁?

Alexa最早由两个合伙人创办于1996年,命名为Alexa互联网公司。名字的灵感来自于著名的亚历山大图书馆(Library of Alexandria)。他们基于用户的数据开发了一个为用户提供网站浏览推荐的“接下来去哪”的工具栏 ...

继续阅读