Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.
You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You could assume there always exists an answer.
Example 1:
1 2 3 4 5
Input: ["Shogun", "Tapioca Express", "Burger King", "KFC"] ["Piatti", "The Grill at Torrey Pines", "Hungry Hunter Steakhouse", "Shogun"] Output: ["Shogun"] Explanation: The only restaurant they both like is "Shogun".
Example 2:
1 2 3 4 5
Input: ["Shogun", "Tapioca Express", "Burger King", "KFC"] ["KFC", "Shogun", "Burger King"] Output: ["Shogun"] Explanation: The restaurant they both like and have the least index sum is "Shogun" with index sum 1 (0+1).
Note:
The length of both lists will be in the range of [1, 1000].
The length of strings in both lists will be in the range of [1, 30].
The index is starting from 0 to the list length minus 1.
classSolution(object): deffindRestaurant(self, list1, list2): """ :type list1: List[str] :type list2: List[str] :rtype: List[str] """ list1Map = {} i = 0 for word in list1: list1Map[word] = i i += 1
minSum = sys.maxint i = 0 restaurants = [] for word in list2: if word in list1Map: if minSum > list1Map[word]+i: print minSum minSum = list1Map[word]+i restaurants = [] restaurants.append(word) elif minSum == list1Map[word]+i: restaurants.append(word) i += 1
How did Vera discover she had this gift of second sight?
Several cases have been reported in Russia recently of people who can read and detect colours with their fingers, and even see through solid doors and walls. One case concerns an eleven-year-old schoolgirl, Vera Petrova, who has normal vision but who can also perceive things with different parts of her skin, and through solid walls. This ability was first noticed by her father. One day she came into his office and happened to put her hand on the door of a locked safe. Suddenly she asked her father why he kept so many old newspapers locked away there, and even described the way they were done up in bundles.
Vera’s curious talent was brought to the notice of a scientific research institute in the town of Ulyanovsk, near where she lives, and in April she was given a series of tests by a special commission of the Ministry of Health of the Russian Federal Republic. During these tests she was able to read a newspaper through an opaque screen and, stranger still, by moving her elbow over a child’s game of Lotto she was able to describe the figures and colours printed on it; and, in another instance, wearing stockings and slippers, to make out with her foot the outlines and colours of a picture hidden under a carpet. Other experiments showed that her knees and shoulders had a similar sensitivity. During all these tests Vera was blindfold; and, indeed, except when blindfold she lacked the ability to perceive things with her skin. It was also found that although she could perceive things with her fingers this ability ceased the moment her hands were wet.
What was the main objective of early mountain climbers?
Modern alpinist try to climb mountains by a route which will give them good sport, and the more difficult it is, the more highly it is regarded. In the pioneering days, however, this was not the case at all. The early climbers were looking for the easiest way to the top, because the summit was the prize they sought, especially if it had never been attained before. It is true that during their explorations they often faced difficulties and dangers of the most perilous nature, equipped in a manner which would make a modern climber shudder at the thought, but they did not go out of their way to court such excitement. They had a single aim, a solitary goal — the top!
It is hard for us to realize nowadays how difficult it was for the pioneers. Except for one or two places such as Zermatt and Chamonix, which had rapidly become popular, Alpine villages tended to be impoverished settlements cut off from civilization by the high mountains. Such inns as there were generally dirty and flea-ridden; the food simply local cheese accompanied by bread often twelve months old, all washed down with coarse wine. Often a valley boasted no inn at all, and climbers found shelter wherever they could sometimes with the local priest(who was usually as poor as his parishioners), sometimes with shepherds or cheese-makes. Invariably the background was the same: dirt and poverty, and very uncomfortable. For men accustomed to eating seven-course dinners and sleeping between fine linen sheets at home, the change to the Alps must have been very hard indeed.
📖 Lesson 03: Matterhorn Man 深度解析
🎯 文章主旨
What was the main objective of early mountain climbers?
Modern alpinists try to climb mountains by a route which will give them good sport, and the more difficult it is, the more highly it is regarded.
翻译: 现代登山者试图通过能给他们带来良好运动体验的路线攀登山峰, 路线越困难,就越受推崇。
核心观点:现代登山 = 追求挑战
1 2 3 4 5
现代登山者的价值观: 难度 ↑ = 荣誉 ↑ - 选择最难的路线 - 挑战极限 - 证明技术和勇气
1
In the pioneering days, however, this was not the case at all.
翻译: 然而,在开拓时期,情况完全不是这样。
转折词 “however” 引出对比
1 2 3
The early climbers were looking for the easiest way to the top, because the summit was the prize they sought, especially if it had never been attained before.
It is true that during their explorations they often faced difficulties and dangers of the most perilous nature, equipped in a manner which would make a modern climber shudder at the thought, but they did not go out of their way to court such excitement.
It is hard for us to realize nowadays how difficult it was for the pioneers.
翻译: 我们现在很难想象当年开拓者们有多么艰难。
写作手法:
引起读者共鸣
为后文铺垫
1 2 3 4
Except for one or two places such as Zermatt and Chamonix, which had rapidly become popular, Alpine villages tended to be impoverished settlements cut off from civilization by the high mountains.
Such inns as there were generally dirty and flea-ridden; the food simply local cheese accompanied by bread often twelve months old, all washed down with coarse wine.
Often a valley boasted no inn at all, and climbers found shelter wherever they could — sometimes with the local priest (who was usually as poor as his parishioners), sometimes with shepherds or cheese-makers.
Invariably the background was the same: dirt and poverty, and very uncomfortable.
翻译: 无一例外,背景都是一样的:肮脏、贫穷,而且非常不舒适。
关键词:
invariably /ɪnˈveriəbli/:总是、无一例外地
in- (not) + vari- (vary变化) + -ably
= 不变地、一成不变地
修辞:
三个并列:dirt, poverty, uncomfortable
递进强调恶劣条件
1 2 3
For men accustomed to eating seven-course dinners and sleeping between fine linen sheets at home, the change to the Alps must have been very hard indeed.
How much of each year do spiders spend killing insects?
Why, you may wonder, should spiders be our friends? Because they destroy so many insects, and insects include some of the greatest enemies of the human race. Insects would make it impossible for us to live in the world; they would devour all our crops and kill our flocks and herds, if it were not for the protection we get from insect-eating animals. We owe a lot to the birds and beasts who eat insects but all of them put together kill only a fraction of the number destroyed by spiders. Moreover, unlike some of the other insect eaters, spiders never do the least harm to us or our belongings.
Spiders are not insects, as many people think, not even nearly related to them. One can tell the difference almost at a glance, for a spider always has eight legs and an insect never more than six.
How many spiders are engaged in this work on our behalf? One authority on spiders made a census of the spiders in a grass field in the south of England, and he estimated that there were more than 2,250,000 in one acre; that is something like 6,000,000 spiders of different kinds of a football pitch. Spiders are busy for at least half the year in killing insects. It is impossible to make more than the wildest guess at how many they kill, but they are hungry creatures, not content with only three meals a day. It has been estimated that the weight of all the insects destroyed by spiders in Britain in one year would be greater than the total weight of all the human beings in the country.
文章讲解
📋 文章主题
这是一篇说明文,主题是:蜘蛛是人类的朋友,因为它们大量捕食昆虫。
🎯 文章结构分析
第一段:蜘蛛的重要作用
核心观点:蜘蛛通过消灭昆虫保护人类
论证逻辑:
昆虫是人类的大敌(会毁坏庄稼、杀死牲畜)
食虫动物保护了我们
蜘蛛杀死的昆虫数量远超其他食虫动物
蜘蛛对人类无害
第二段:蜘蛛与昆虫的区别
纠正常见误解:蜘蛛不是昆虫
简单辨别方法:蜘蛛8条腿,昆虫最多6条腿
第三段:惊人的数据
用具体数字说明蜘蛛的贡献:
密度:英格兰南部草地,每英亩超过225万只蜘蛛
换算:一个足球场大小约有600万只不同种类的蜘蛛
工作时长:每年至少半年在捕食昆虫
食量:英国蜘蛛一年消灭的昆虫总重量 > 全国人口总重量
📚 重点词汇解析
单词
词性
含义
用法
devour
v.
吞食,毁灭
devour all our crops
flocks
n.
羊群
flocks and herds(成对使用)
herds
n.
牛群
指大型牲畜群
beasts
n.
野兽,动物
birds and beasts(鸟兽)
glance
n.
一瞥
at a glance(一眼就能看出)
behalf
n.
利益,代表
on our behalf(为我们)
census
n.
普查,统计
make a census of…
acre
n.
英亩
面积单位(约4047平方米)
pitch
n.
球场
football pitch(足球场)
✨ 精彩表达
“insects include some of the greatest enemies of the human race”
昆虫是人类最大的敌人之一
“all of them put together kill only a fraction of…”
所有这些加起来也只杀死了一小部分
put together = 加在一起
“never do the least harm to us”
从不对我们造成丝毫伤害
not the least = 一点也不
“not content with only three meals a day”
不满足于一日三餐
形容蜘蛛食量大
🔢 回答标题问题
“How much of each year do spiders spend killing insects?”
Why are legends handed down by storytellers useful?
We can read of things that happened 5,000 years ago in the Near East, where people first learned to write. But there are some parts of the world where even now people cannot write. The only way that they can preserve their history is to recount it as sagas - legends handed down from one generation of storyteller to another. These legends are useful because the can tell us something about migrations of people who lived long ago, but none could write down what they did. Anthropologist wondered where the remote ancestors of the Polynesian peoples now living in the Pacific Islands came from. The sagas of these people explain that some of them came from Indonesia about 2,000 years ago.
But the first people who were like ourselves lived so long ago that even their sagas, if they had any, are forgotten. So archaeologists have neither history nor legends to help them find out where the first “modern men” came from.
Fortunately, however, ancient men made tools of stone, especially flint, because this is easier to shape than other kinds. They may also have used wood and skins, but these have rotted away. Stone does not decay, and so the tools of lone ago have remained when even the bones of the men who made them have disappeared without trace.
📖 文章主题
探讨人类如何通过文字记录、口头传说和考古发现来了解古代人类的历史。
🎯 核心问题回答
Why are legends handed down by storytellers useful?
Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,2], a solution is:
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimited number of times.
Note:
All numbers (including target) will be positive integers.
The solution set must not contain duplicate combinations. For example, given candidate set [2, 3, 6, 7] and target 7, A solution set is: