难度系数: 简单
给你一个整数 x ,如果 x 是一个回文整数,返回 true ;否则,返回 false 。
回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。
例如,121 是回文,而 123 不是。

阅读全文 »

难度系数: 简单

给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。

说明:
你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗?

阅读全文 »

如何进行代码审查

The pages in this section contain recommendations on the best way to do code reviews, based on long experience. All together they represent one complete document, broken up into many separate sections. You don’t have to read them all, but many people have found it very helpful to themselves and their team to read the entire set.

本文档包含了关于代码审查最佳实践的一些建议,这些建议都是基于长期实践总结出来的。我们将在不同的章节对它们进行阐述。你无需全部阅读它们,但很多人发现读完整个文档对他们自己或者团队都非常有帮助。

阅读全文 »

Introduction(介绍)

A code review is a process where someone other than the author(s) of a piece of code examines that code.
所谓的代码审查(code review)就是指让别人来审查自己的代码的过程。

At Google, we use code review to maintain the quality of our code and products.
在Google内部,我们会通过代码审查来保证代码和产品的质量。

This documentation is the canonical description of Google’s code review processes and policies.
本文档详述了Google是如何进行代码审查的以及所采用的策略。

阅读全文 »

Remote procedure call (RPC,远程过程调用)

In the second tutorial we learned how to use Work Queues to distribute time-consuming tasks among multiple workers.

在教程2里我们学习了如何使用工作队列在多个工作者之间分发耗时任务。

But what if we need to run a function on a remote computer and wait for the result? Well, that’s a different story. This pattern is commonly known as Remote Procedure Call or RPC.

但如果我们需要在一个远程电脑上运行一个函数并且等待运行结果的话要怎么办呢?这就变成另一个问题了。这种模式通常被称为远程过程调用(Remote Procedure Call),或者简称RPC。

In this tutorial we’re going to use RabbitMQ to build an RPC system: a client and a scalable RPC server. As we don’t have any time-consuming tasks that are worth distributing, we’re going to create a dummy RPC service that returns Fibonacci numbers.

在本节教程里,我们将用RabbitMQ来构建一个RPC系统,这个系统包括一个客户端和一个可伸缩的RPC服务端。由于我们没有什么耗时任务值得分发,所以我们准备创建一个假的RPC服务,这个服务返回斐波那契(Fibonacci)数值。

阅读全文 »

Topics(主题)

In the previous tutorial we improved our messaging flexibility. Instead of using a fanout exchange only capable of dummy broadcasting, we used a direct one, and gained a possibility of selectively receiving the message based on the routing key.

在上一个教程里我们改善了我们的消息队列的灵活性。我们使用直接交换器来替代只会傻傻地广播消息的广播交换器,使得根据路由键来选择性接收消息成为了可能。

Although using the direct exchange improved our system, it still has limitations - it can’t do routing based on multiple criteria.

虽然使用直接交换器改善了我们的系统,但它仍然有一些限制——它无法根据多个标准来进行路由。

阅读全文 »

Routing(路由)

In the previous tutorial we built a simple fanout exchange. We were able to broadcast messages to many receivers.

在上一个教程里,我们构建了一个简单的广播交换器。通过它我们能将消息广播到多个接收者。

In this tutorial we’re going to add a feature to it - we’re going to make it possible to subscribe only to a subset of the messages. For example, we will be able to direct only messages to the certain colors of interest (“orange”, “black”, “green”), while still being able to print all of the messages on the console.

在本教程里,我们将往里添加一个功能——我们准备让接收者可以只订阅部分消息。例如,我们将只要某些我们感兴趣的颜色(“橙色”,“黑色”,“绿色”)的消息,但仍能在控制台里打印出所有的信息。

阅读全文 »

Publish/Subscribe(发布/订阅)

In the first tutorial we showed how to use start.spring.io to leverage Spring Initializr to create a project with the RabbitMQ starter dependency for create spring-amqp applications.

在第一个教程中,我们展示了如何通过start.spring.io上的Spring初始化手脚架来创建一个包含了RabbitMQ starter依赖的项目,并以此创建基于spring-amqp的应用。

In the previous tutorial we created a new package (tut2) to place our config, sender and receiver and created a work queue with two consumers. The assumption behind a work queue is that each task is delivered to exactly one worker.

在上一个教程当中,我们创建了一个新的包(tut2)来放置我们的配置类,发送者类和接收者类,并创建了一个对应着两个消费者的队列。工作队列背后的原理假设是,每个任务都发送给某个恰当的工作者。

In this part we’ll implement the fanout pattern to deliver a message to multiple consumers. This pattern is known as “publish/subscribe” and is implementing by configuring a number of beans in our Tut3Config file.

在这部分教程中,我们将实现广播模式(fanout pattern),从而将一条消息发送给多个消费者。这个模式被称为“发布/订阅”,我们将在Tut3Config文件里配置一系列bean来实现这个模式。

阅读全文 »

2 工作队列(Work Queues)

image

In the first tutorial we wrote programs to send and receive messages from a named queue. In this one we’ll create a Work Queue that will be used to distribute time-consuming tasks among multiple workers.

在第一个教程中,我们编写了两个程序,一个用于往一个命名了的队列发送消息,另一个从这个队列里接收消息。在本教程里,我们将创建一个工作队列(Work Queue),它将被用来在多个工作者之间分发耗时任务。

阅读全文 »
0%