Posts

Maximum Gap

Question: http://www.lintcode.com/en/problem/maximum-gap/ Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Return 0 if the array contains less than 2 elements. Sort is easy but will cost O(nlogn) time. Try to solve it in linear time and space. Answer: class Solution { public: int maximumGap(vector<int> &num) { if (num.size() < 2) return 0; int maxNum = num[0]; int minNum = num[0]; for (int x : num) { maxNum = max(maxNum, x); minNum = min(minNum, x); } int len = (maxNum - minNum) / num.size() + 1; vector<vector<int>> buckets((maxNum - minNum) / len + 1); for (int x : num) { int i = (x - minNum) / len; if (buckets[i].empty()) { buckets[i].reserve(2); buckets[i].push_back(x); buckets[i].push_back(x); ...

HOW CHRIST MET A REAL NEED

Image
第三日,在加利利的迦拿有娶亲的筵席,耶稣的母亲在那里。 (约翰福音 2:1 和合本) On the third day a wedding took place at Cana in Galilee. Jesus' mother was there, (John 2:1 NIV) 耶稣和他的门徒也被请去赴席。 (约翰福音 2:2 和合本) and Jesus and his disciples had also been invited to the wedding. (John 2:2 NIV) 酒用尽了,耶稣的母亲对他说:"他们没有酒了。" (约翰福音 2:3 和合本) When the wine was gone, Jesus' mother said to him, "They have no more wine." (John 2:3 NIV) 耶稣说:"母亲(原文是妇人) ,我与你有什么相干?我的时候还没有到。" (约翰福音 2:4 和合本) "Woman, why do you involve me?"Jesus replied. "My hour has not yet come." (John 2:4 NIV) 他母亲对用人说:"他告诉你们什么,你们就做什么。" (约翰福音 2:5 和合本) His mother said to the servants, "Do whatever he tells you." (John 2:5 NIV) 照犹太人洁净的规矩,有六口石缸摆在那里,每口可以盛两三桶水。 (约翰福音 2:6 和合本) Nearby stood six stone water jars, the kind used by the Jews for ceremonial washing, each holding from twenty to thirty gallons. (John 2:6 NIV) 耶稣对用人说:"把缸倒满了水。"他们就倒满了,直到缸口。 (约翰福音 2:7 和合本) Jesus said to...

The LORD is great

Image
愿一切寻求你的,因你高兴欢喜;愿那些喜爱你救恩的,常说:当尊 神为大! (诗篇 70:4 和合本) But may all who seek you rejoice and be glad in you; may those who long for your saving help always say, "The Lord is great!" (Psalms 70:4 NIV) 但我是困苦穷乏的; 神啊,求你速速到我这里来!你是帮助我的,搭救我的。耶和华啊,求你不要耽延! (诗篇 70:5 和合本) But as for me, I am poor and needy; come quickly to me, O God. You are my help and my deliverer; Lord , do not delay. (Psalms 70:5 NIV) Photo by Justin Kauffman / Unsplash

Recommend text editor : Sublime Text

A sophisticated text editor for code, markup and prose

been tempted, yet he did not sin

Image
当时,耶稣被圣灵引到旷野,受魔鬼的试探。 (马太福音 4:1 和合本) Then Jesus was led by the Spirit into the wilderness to be tempted by the devil. (Matthew 4:1 NIV) 他禁食四十昼夜,后来就饿了。 (马太福音 4:2 和合本) After fasting forty days and forty nights, he was hungry. (Matthew 4:2 NIV) 那试探人的进前来,对他说:"你若是 神的儿子,可以吩咐这些石头变成食物。" (马太福音 4:3 和合本) The tempter came to him and said, "If you are the Son of God, tell these stones to become bread." (Matthew 4:3 NIV) 耶稣却回答说:"经上记着说:人活着,不是单靠食物,乃是靠 神口里所出的一切话。" (马太福音 4:4 和合本) Jesus answered, "It is written: 'Man shall not live on bread alone, but on every word that comes from the mouth of God.' " (Matthew 4:4 NIV) 魔鬼就带他进了圣城,叫他站在殿顶(顶:原文是翅) 上, (马太福音 4:5 和合本) Then the devil took him to the holy city and had him stand on the highest point of the temple. (Matthew 4:5 NIV) 对他说:"你若是 神的儿子,可以跳下去,因为经上记着说:主要为你吩咐他的使者用手托着你,免得你的脚碰在石头上。" (马太福音 4:6 和合本) "If you are the Son of God," he said, "throw yourself down. For it is wri...

Christ Begins His Ministry

Image
当下,耶稣从加利利来到约旦河,见了约翰,要受他的洗。 (马太福音 3:13 和合本) Then Jesus came from Galilee to the Jordan to be baptized by John. (Matthew 3:13 NIV) 约翰想要拦住他,说:"我当受你的洗,你反倒上我这里来吗?" (马太福音 3:14 和合本) But John tried to deter him, saying, "I need to be baptized by you, and do you come to me?" (Matthew 3:14 NIV) 耶稣回答说:"你暂且许我,因为我们理当这样尽诸般的义(或译:礼) 。"于是约翰许了他。 (马太福音 3:15 和合本) Jesus replied, "Let it be so now; it is proper for us to do this to fulfill all righteousness."Then John consented. (Matthew 3:15 NIV) 耶稣受了洗,随即从水里上来。天忽然为他开了,他就看见 神的灵仿佛鸽子降下,落在他身上。 (马太福音 3:16 和合本) As soon as Jesus was baptized, he went up out of the water. At that moment heaven was opened, and he saw the Spirit of God descending like a dove and alighting on him. (Matthew 3:16 NIV) 从天上有声音说:"这是我的爱子,我所喜悦的。" (马太福音 3:17 和合本) And a voice from heaven said, "This is my Son, whom I love; with him I am well pleased." (Matthew 3:17 NIV) Photo by Simon Matzinger / Unsplash

Listen

Image
"只是我告诉你们这听道的人,你们的仇敌,要爱他!恨你们的,要待他好! (路加福音 6:27 和合本) "But to you who are listening I say: Love your enemies, do good to those who hate you, (Luke 6:27 NIV) 咒诅你们的,要为他祝福!凌辱你们的,要为他祷告! (路加福音 6:28 和合本) bless those who curse you, pray for those who mistreat you. (Luke 6:28 NIV) 有人打你这边的脸,连那边的脸也由他打。有人夺你的外衣,连里衣也由他拿去。 (路加福音 6:29 和合本) If someone slaps you on one cheek, turn to them the other also. If someone takes your coat, do not withhold your shirt from them. (Luke 6:29 NIV) 凡求你的,就给他。有人夺你的东西去,不用再要回来。 (路加福音 6:30 和合本) Give to everyone who asks you, and if anyone takes what belongs to you, do not demand it back. (Luke 6:30 NIV) 你们愿意人怎样待你们,你们也要怎样待人。 (路加福音 6:31 和合本) Do to others as you would have them do to you. (Luke 6:31 NIV) Photo by Artem Sapegin / Unsplash