Google – Remove Alarm



Google – Remove Alarm

有一堆Alarm, 每个alarm有三个值,start time, end time和priority。要求是把那些从没有成为过最高优先级的alarm给删除。

比如有这么几个alarms:

Alarm1 (1, 2, 1)
Alarm2 (1, 4, 2)
Alarm3 (3, 5, 3)
Alarm4 (3, 4, 2)

那么比如alarm1和alarm4就是要删除的。因为alarm1和alarm2同时开始,但是第二个优先级高,等第二个结束的时候第一个alarm早就结束了。所以第一个alarm从来没有到过最高优先级。alarm4也是一样。

[Solution]
这道题学会了一种新的算法:scan-line algorithm,中文叫扫描线算法。Leetcode里的the skyline problem使用的也是这种算法。


Read full article from Google – Remove Alarm


Google Stock: Alphabet Inc Wins $4-Billion Jackpot



Google Stock: Alphabet Inc Wins $4-Billion Jackpot

By Gaurav S. Iyer, IFC Published: November 30, 2016 By Gaurav S. Iyer, IFC Published : November 30, 2016 Photo: Spencer Platt/Getty Images Most people think the smartphone boom is over, but a new report suggests that Alphabet Inc (NASDAQ:GOOG), also known as Google, can still squeeze a little more growth out of the sector. The "Pixel," its new high-end smartphone, is expected to be a cash cow in 2017. For instance, analysts at Morgan Stanley's (NYSE:MS) research division think that Google will sell five to six million smartphones next year. It will be a massive haul for the company and Google stock, bringing in $3.8 billion from the product release. The trend is already underway. Google is on track to sell three million Pixels before the end of the year, at least according to the preliminary data. Since the phones retail between $649.00 and $869.00, the company could eke out $2.0 billion of revenue this quarter alone.

Read full article from Google Stock: Alphabet Inc Wins $4-Billion Jackpot


Finding sum of even terms in Fibonacci series – Oracle Java Combo



Finding sum of even terms in Fibonacci series – Oracle Java Combo

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.


Read full article from Finding sum of even terms in Fibonacci series – Oracle Java Combo


how to load additional bean configuration file in spring at run time - Stack Overflow



how to load additional bean configuration file in spring at run time - Stack Overflow

If you're using the classpath scanning but you still want o load additional configurations from XML, you can simply use the @ImportResource annotation on your @Configuration class and import the XML resource you need: @Configuration @ImportResource( { "classpath*:/rest_config.xml" } ) public class MyConfig{ ... } That way it's easy to mix in legacy XML configuration with newer, Java configs and you don't have to - for example - migrate your entire configuration in one go.

Read full article from how to load additional bean configuration file in spring at run time - Stack Overflow


java - Parsing nested objects with Jackson - Stack Overflow



java - Parsing nested objects with Jackson - Stack Overflow

The main problem lies inside of UserPreferences. Right now your code is attempting to deserialize "1" as a boolean. Java will not do this translation for you, so you will need to create a custom deserializer and apply it to the fields with numeric booleans.


Read full article from java - Parsing nested objects with Jackson - Stack Overflow


Add @JsonWrapped · Issue #512 · FasterXML/jackson-databind



Add @JsonWrapped · Issue #512 · FasterXML/jackson-databind

It would be nice to have the inverse of @JsonUnwrapped.

This would enable serializing this class:


Read full article from Add @JsonWrapped · Issue #512 · FasterXML/jackson-databind


San Francisco passes resolution against Trump | Fusion



San Francisco passes resolution against Trump | Fusion

San Francisco's Board of Supervisors took a symbolic step to formally oppose Donald Trump last week, passing a resolution that reaffirms the city's commitment to things like LGBTQ rights, religious freedoms, and racial, social, and economic justice—values largely at risk under the incoming Trump administration. Here's the full text: WHEREAS, On November 8, 2016, Donald Trump was elected to become the 45th President of the United States; now, therefore, be it RESOLVED, That no matter the threats made by President-elect Trump, San Francisco will remain a Sanctuary City. We will not turn our back on the men and women from other countries who help make this city great, and who represent over one third of our population. This is the Golden Gate-we build bridges, not walls; and, be it FURTHER RESOLVED, That we will never back down on women's rights, whether in healthcare, the workplace,

Read full article from San Francisco passes resolution against Trump | Fusion


SF programs at risk under sanctuary city defunding - SFGate



SF programs at risk under sanctuary city defunding - SFGate

Emily Green | on November 28, 2016 Photo: Amy Osborne, The Chronicle Image 1of/6 Photo: Amy Osborne, The Chronicle Image 2 of 6 San Francisco Mayor Ed Lee speaks during a meeting at City Hall in San Francisco by city leaders and community activists to reaffirm the city's commitment to being a sanctuary city in response to Donald Trump's support of deportations and other measures against immigrants Monday, Nov. 14, 2016. less San Francisco Mayor Ed Lee speaks during a meeting at City Hall in San Francisco by city leaders and community activists to reaffirm the city's commitment to being a sanctuary city in response to Donald Trump's ... more Photo: Jeff Chiu, Associated Press Image 3 of 6 San Francisco Mayor Ed Lee, right,

Read full article from SF programs at risk under sanctuary city defunding - SFGate


Algorithms-Puzzles/RepeatedSubstring.md at master · kuldeepiitg/Algorithms-Puzzles



Algorithms-Puzzles/RepeatedSubstring.md at master · kuldeepiitg/Algorithms-Puzzles

Given an input string S write a function which returns true if it satisfies S = nT. Basically you have to find if a given string can be represented from a substring by iterating it "n" times. n >= 2

Function should return true if
1) S = "abab"
2) S = "abcdabcd"
3) S = "abcabcabc"
4) S = "zzxzzxzzx"
Function should return false if
1) S = "abac"
2) S = "abcdabbd"
3) S = "abcabcefg"
4) S = "zzxzzyzzx"

Algorithm :

Start writing substring from start. If next coming substring is not matching then concatenate it with existing.


Read full article from Algorithms-Puzzles/RepeatedSubstring.md at master · kuldeepiitg/Algorithms-Puzzles


(3) Google: How difficult is it to transition from Software Engineer, Tools and Infrastructure (SETI) to SWE at Google within an year of joining? - Quora



(3) Google: How difficult is it to transition from Software Engineer, Tools and Infrastructure (SETI) to SWE at Google within an year of joining? - Quora

Why not just join as a SWE if that's the role you prefer? Ladder transfers at Google are possible, and I would say even mildly encouraged but it's not like there's a secret backdoor to the SWE job. AFAICT, everyone who holds it deserves it, even the transfers. :)

(If you have an SET offer, and you believe you could qualify as SWE there's no harm in taking the SET position. There is no penalty for trying to do a transfer and failing. In fact, Google is highly supportive of people reaching beyond their grasp and failing a time or two. That's how we learn!)


Read full article from (3) Google: How difficult is it to transition from Software Engineer, Tools and Infrastructure (SETI) to SWE at Google within an year of joining? - Quora


【新提醒】关于Google SETI和SWE的碎碎念【一亩三分地论坛找工求职版】 - Powered by Discuz!



【新提醒】关于Google SETI和SWE的碎碎念【一亩三分地论坛找工求职版】 - Powered by Discuz!

最近看到地里有好几个帖子问关于G家SETI的事情,楼主当初面之前也云里雾里的,感觉这方面信息比较缺,现在专门开一帖来回馈地里。
如果你拿到SETI,基本上是两个情况:
1、onsite没面好加面的SETI
2、电面recruiter直接说来onsite SETI
楼主是第二种情况,当时也不知道SETI是什么傻傻的就答应了(全名Software Engineer, Tools and Infrastructure),然后recruiter就给楼主洗脑SETI如何如何好然后说到时候面试一定会考testing。(因为楼主research做的是software testing方向的当时还以为只是为了方向match而已)
接下来的问题:. from: 1point3acres.com/bbs
1、SETI面什么?
从楼主的经历来看,跟SWE其实没有什么差,就是面试官会有SETI而且会略微涉及testing。但楼主的四轮里面只有一轮写完代码了以后面试官问how will you test it,一个简单的method,楼主blah blah white box black box unit test system test说了一堆……所以感觉SETI面试要有基本的testing常识就好了,知道要从哪几个方面能全面测试, 真的Software Engineering里面非常基础的就够用了
2、SETI做什么?为什么好像大家不喜欢SETI?
Internal tools 顾名思义就是产品对内使用,就是build and test framework之类的。基本上一个组可能会配一两个SETI这样。
因为楼主onsite的时候中午带楼主吃饭的是一个中国的SETI大哥,所以说了很多SETI的信息。.1point3acres缃�
当初recruiter打电话来的时候说"SETI比一般SWE好啊你team会有很多senior member", 其实良心大哥告诉我那是因为大部分年轻人都跑了SETI常年招不到人所以都是四五十岁的老头子……bar比较低……所以recruiter来坑你了。他当时转成SETI是因为SWE没有headcount才来的……SETI的deadline会比较松因为不是要对外release的东西,做的事情成就感也比较低,当然工资是一样的。.1point3acres缃�
3、如果我拿到SETI的面试,想转成SWE,容易吗?
(1)之前看到地里有人发是拿到了SETI的onsite跟recruiter要求转成SWE面试的,感觉这个是最容易的一条路。
(2)楼主的经历比较奇葩。先是onsite前身边有朋友是SWE面试挂了换了SETI。。。。然后onsite的时候又听良心大哥blah blah了一堆心情十分抑郁……回去之后给recruiter写了个邮件问有没有办法换成SWE然后recruiter完全没鸟我……结果过了HC之后说给我搞了一个SWE一个SETI的package同时去批……最后直接给了SWE,也没有加面。Recruiter说楼主的feedback很strong不知道是不是这个原因……反正不知道发生了什么>_>但是只要在最后offer出来之前应该想换都是有机会的。
(3)入职之后再换。其实这是最难的一个了,楼主之前也是这么想的。Onsite的时候良心大哥表示他在这边呆了两三年了都没办法换到SWE,貌似是要换一个什么SWE ladder还是怎么样,但是一般你的manager都不想让你跑要不然招不到人了……所以比一般SWE转组要难很多。有SETI转的是因为在所属的组里做了SWE的20% project然后正好缺人就过去了,还有一个manager自己是SETI出身自己深知其苦所以专门招SETI转SWE的过来...而且一般组里也宁愿找new grad而不是SETI转的。。。忘了啥原因了……

其实楼主真心觉得……尤其是听了良心大哥说了以后……觉得能尽早换成SWE面还是换成SWE,这样面挂了还是有机会加面去SETI的,楼主这个奇葩情况也不知道是什么原因可能属于运气好的……而且SETI的主要问题是内部转组其实不容易。当然,SETI的bar据说确实低一点,可能确实比较容易进而且也比较缺人,应该是比较安稳的。

地里如果还有SETI哥哥姐姐correct me if I'm wrong...毕竟我也没有自己做过都是听说的哈

Read full article from 【新提醒】关于Google SETI和SWE的碎碎念【一亩三分地论坛找工求职版】 - Powered by Discuz!


refactoring extract constant



refactoring extract constant

The in-place refactorings are enabled in IntelliJ IDEA by default. So, if you haven't changed this setting, the Extract Constant refactoring for Java is performed in-place, right in the editor:

  1. Place the cursor within the expression or declaration of a variable to be replaced by a constant.
  2. Do one of the following:
    • Press ⌥⌘C.
    • Choose Refactor | Extract Constant on the main menu or on the context menu.

Read full article from refactoring extract constant


Analyzing external stack traces | IntelliJ IDEA Blog



Analyzing external stack traces | IntelliJ IDEA Blog

As a developer, you certainly get exceptions from users or QA engineers. And unlike the exceptions that you get in the debug mode, they don’t have those nice links that help you to navigate to source. If your source code is scrambled, the things get even more complicated.
Now imagine that you can simply copy an exception to your IDE and then navigate to source from the console. How much time will it save?

Read full article from Analyzing external stack traces | IntelliJ IDEA Blog


java - Stack Trace Console in IntelliJ IDEA - Stack Overflow



java - Stack Trace Console in IntelliJ IDEA - Stack Overflow

Does IntelliJ have an equivalent to Eclipse's "Java Stack Trace Console," where you can paste in a stack trace and it will linkify it for you if it matches any of the source files in your project?


Read full article from java - Stack Trace Console in IntelliJ IDEA - Stack Overflow


Powerful Number - GeeksforGeeks



Powerful Number - GeeksforGeeks

A number n is said to be Powerful Number if for every prime factor p of it, p2 also divides it. For example:- 36 is a powerful number. It is divisible by both 3 and square of 3 i.e, 9.

The first few Powerful Numbers are:
1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64 ….

Given a number n, our task is to check if this is powerful or not.
Examples:

Input: 27  Output: YES    Input: 32  Output: YES    Input: 12  Output: NO  

We strongly recommend you to minimize your browser and try this yourself first.

The idea is based on the fact that if a number n is powerful, then all prime factors of it and their squares should be divisible by n. We find all prime factors of given number. And for every prime factor, we find the highest power of it that divides n. If we find a prime factor whose highest dividing power is 1, we return false. If highest dividing power of all prime factors is more than 1, we return true.


Read full article from Powerful Number - GeeksforGeeks


Hexagonal Number - GeeksforGeeks



Hexagonal Number - GeeksforGeeks

Given an integer n, the task is to find the n'th hexagonal number . The n'th hexagonal number Hn is the number of distinct dots in a pattern of dots consisting of the outlines of regular hexagons with sides up to n dots, when the hexagons are overlaid so that they share one vertex.{Source : wiki}

Input : n = 2  Output : 6    Input : n = 5  Output : 45    Input : n = 7  Output : 91    

We strongly recommend you to minimize your browser and try this yourself first.

In general, a polygonal number (triangular number, square number, etc) is a number represented as dots or pebbles arranged in the shape of a regular polygon. The first few pentagonal numbers are: 1, 5, 12, etc.
If s is the number of sides in a polygon, the formula for the nth s-gonal number P (s, n) is


Read full article from Hexagonal Number - GeeksforGeeks


List of Google Now voice commands



List of Google Now voice commands

Phones don't really come with instruction manuals anymore, and learning how to use your phone effectively can be a big task. Our tips and how-to articles will set you on the path to Android expertise. Update A list of all the Google Now voice commands What can you do with your voice on your Android phone? More than you know! Greenbot | Aug 25, 2016 9:23 AM PT Email a friend From Sorry Credit: Jason Cross More like this You pick up your phone and say "OK Google"... and then what? Your phone is listening. The microphone icon is pulsing. What do you say to your phone? What can you say to it? Google Now's voice function has become surprisingly robust over the years. Here's a list of just about everything you can say to Google Now. Try experimenting with different phrasing, you'll be surprised how much it understands. The part of the phrase in [brackets] can be replaced with any similar term you choose. If Google Now doesn't get your spoken commands right, you can correct it by saying "No,

Read full article from List of Google Now voice commands


Least frequently used cache eviction scheme with complexity O(1) in Python | Laurent Luce's Blog



Least frequently used cache eviction scheme with complexity O(1) in Python | Laurent Luce's Blog

This post describes the implementation in Python of a "Least Frequently Used" (LFU) algorithm cache eviction scheme with complexity O(1). The algorithm is described in this paper written by Prof. Ketan Shah, Anirban Mitra and Dhruv Matani. The naming in the implementation follows the naming in the paper.

LFU cache eviction scheme is useful for an HTTP caching network proxy for example, where we want the least frequently used items to be removed from the cache.

The goal here is for the LFU cache algorithm to have a runtime complexity of O(1) for all of its operations, which include insertion, access and deletion (eviction).

Doubly linked lists are used in this algorithm. One for the access frequency and each node in that list contains a list with the elements of same access frequency. Let say we have five elements in our cache. Two have been accessed one time and three have been accessed two times. In that case, the access frequency list has two nodes (frequency = 1 and frequency = 2). The first frequency node has two nodes in its list and the second frequency node has three nodes in its list.


Read full article from Least frequently used cache eviction scheme with complexity O(1) in Python | Laurent Luce's Blog


动物庄园 | Tengfei's Notes



动物庄园 | Tengfei's Notes

在我看来,整本书都在讲一个寓意深刻的寓言。

《动物庄园》是乔治奥威尔一本很有名的反乌托邦小说,关于这本书的书评和解析也到处都是,稍微一查就知道是在影射俄国十月革命。这里就就记录一下自己看完之后的想法。

我觉得就像整本书描述的过程一样,我相信一切起义或革命的开端都是好的,但是随着统治者拥有的权利在慢慢变大变强的时候,他们就开始慢慢忘了自己,忘了自己的本质也是一个和大家一样平等的人,只不过被大家选出来做为集体利益的代表。这一点从动物们刚开始起义时的''七戒'':

  1. 凡用两条腿行走的都是敌人。
  2. 凡四条腿行走或长翅膀的,都是朋友。
  3. 凡动物都不可穿衣服。
  4. 凡动物都不可睡床铺。
  5. 凡动物都不可饮酒。
  6. 凡动物都不可杀任何别的动物。
  7. 凡动物一律平等。

到后来统治者逐渐占据垄断地位之后的更改后的"新七戒":

1+2. 四条腿好,两条腿更好。

3. 猪也穿上了人类的衣服。

4. 凡动物都不可睡床铺被单。

5. 凡动物都不可饮酒过量。

6. 变成了残酷的同类的杀戮,甚至拳击手也没逃厄运。

7. 凡动物一律平等,但是有些动物比别的动物更加平等。

可以看出来,动物本的初衷是推翻庄园中人类对他们的统治,追求一切动物的平等共处。但是当猪慢慢成为统治着之后,一切的条款正在慢慢被修改着,朝着猪慢慢变得像人的方向修改着,文章的最后,当猪最终用两条腿站立的时候,庄园的动物们已经分不清屋里的统治者到底是人还是猪了。

其实这就是人性。说到这里我就联想到国内一些被逮捕的贪官。曾看过一篇报道,写的是一个贪官入狱后写的一篇忏悔书。书中写到,在学生时期的他是一位来自贫苦山区,怀有高远抱负的热血青年。年轻时的他也曾谨记母亲的教导,励志做一位对人民有贡献的父母官。权利是会让人着迷的。着迷于它的一切轻而易举。所以,我觉得人能时刻清醒的认识自己,是很难也很重要的。

书中另一个让我印象深刻的角色是一头名叫斯诺鲍的马。

他本来也是起义的领导人之一,后来在权利的争夺中,被领导者驱逐出境,并被宣布为革命的敌人。同是,如果在庄园中发生了什么不好的事情,比如动物们一直努力修建的风车被暴风雨刮倒,统治者为了安抚众动物,竟然诬陷是斯诺鲍趁着暴风雨的黑夜把风车搞坏的,同是再找一堆拥趸附庸一下,民众们竟然信以为真。

我不知道是民众只是想把自己的愤怒找一处发泄,还是真的这么好被愚弄。这让我想起我们现实世界中的新闻媒体。

我们一直所生活的世界,我们的世界观,是被我们所接受的信息建立起来的,如果环境一直给你灌输一种价值观,可能你就会一直觉得这就是一种正确的价值观。有时候我会想,一些我们从小就被教育的东西,到底是真的假的,或者是对的错的。比如,集体主义。为什么集体的利益就要凌驾于个人之上呢?我觉得首先每个人要有平等的权益,在自己权益没有得到侵犯的情况下,再考虑集体的利益好比锦上添花。但是在个人利益都无法保证的情况下,去谈集体利益,这种"损己利人"的主张,如果在没有其他监管或强制机制的情况下是不会被人们普遍和长久的接受的。比如教师的父亲重病,不去见最后一面而留在学校上课。不会游泳的小伙见义勇为最后牺牲自己救起落水者。这些事例就不详细说了。


Read full article from 动物庄园 | Tengfei's Notes


Right-wing group led by Trump propagandist launches campaign against Elon Musk, Tesla and SpaceX | Electrek



Right-wing group led by Trump propagandist launches campaign against Elon Musk, Tesla and SpaceX | Electrek

4.76 A right-wing propaganda group led by one of Donald Trump's top propagandists recently launched a campaign called 'Stop Elon From Failing Again'. According to their manifesto, the initiative aims to stop Elon Musk from "defrauding" American taxpayers through his companies, Tesla and SpaceX. The effort is backed by conservative public relations specialists and Trump insiders which are funded by fossil fuel interests. Unsurprisingly, it is full of misinformation about Tesla, electric vehicles, and solar energy. The group 'Citizens for the Republic' was first launched by Ronald Reagan in the 70s, but was dismantled after his presidency. Laura Ingraham, a conservative pundit and top Trump propagandist during the election through her radio show and TV appearances, led the relaunch of the group as a political action committee (PAC) last year. She is now the 'National Chairman' of the organization that just launched the campaign against Musk and his companies.

Read full article from Right-wing group led by Trump propagandist launches campaign against Elon Musk, Tesla and SpaceX | Electrek


This 5-second video will crash your iPhone - The Verge



This 5-second video will crash your iPhone - The Verge

hard reset In our video demonstration of the bug above, you'll see that a link to the video, delivered via iMessage, will make iOS 10 play the file in the default player. It appears that the video is corrupt, generating a loop that causes the iPhone to crash around 10 seconds after watching it. We're not linking to the video for obvious reasons, but it appears to only crash devices when it's sent as a link rather than simply transferred as a file. The only way to recover from the crash is to hold the power button and home button at the same time to perform a hard reset. An iPhone will work as normal once it has rebooted this way. This isn't the first time that a crash bug has been discovered in iOS. Last year, a string of text  disabled Apple's iMessage app on iPhones, and the company  addressed the problem with iOS 8.4 . Earlier this year, Safari started  randomly crashing on iPhones due to a software issue that was quickly resolved.

Read full article from This 5-second video will crash your iPhone - The Verge


是阻塞還是吸奶器沒力?(頁 1) - ㄋㄟㄋㄟ問答區 - ㄋㄟㄋㄟ共和國 - Powered by Discuz! Archiver



是阻塞還是吸奶器沒力?(頁 1) - ㄋㄟㄋㄟ問答區 - ㄋㄟㄋㄟ共和國 - Powered by Discuz! Archiver

其實親餵久了,真的會覺得吸奶器的力道不足!
我以前是用貝瑞克雙邊的,用沒多久就因為想要全親餵就束之高閣。
後來寶寶奶量變少,漲奶有硬塊時我就拿出來用,
可是把吸力開到最強而且只用一邊還是沒反應,我根本感覺不到有吸力!
後來我就很認命的用手擠,真的比較好用~


Read full article from 是阻塞還是吸奶器沒力?(頁 1) - ㄋㄟㄋㄟ問答區 - ㄋㄟㄋㄟ共和國 - Powered by Discuz! Archiver


Caching Data in Spring Using Redis · caseyscarborough.com



Caching Data in Spring Using Redis · caseyscarborough.com

Caching is a way for applications to store data so that future requests to the same data are returned faster and do not require repeating computationally expensive operations. The Spring Framework provides a simple way to cache the results of method calls with little to no configuration.

The examples in this post use Spring 4.1.3 and Spring Data Redis 1.4.1, the latest versions at the time of this writing. Full source code for this post can be found here.


Read full article from Caching Data in Spring Using Redis · caseyscarborough.com


About pull request reviews - GitHub Enterprise 2.8 Documentation



About pull request reviews - GitHub Enterprise 2.8 Documentation

After a pull request is opened, anyone with read access can review and comment on the changes it proposes. Reviews allow for discussion of proposed changes and help ensure that the changes meet the repository's contributing guidelines and other quality standards.


Read full article from About pull request reviews - GitHub Enterprise 2.8 Documentation


Lucas Numbers - GeeksforGeeks



Lucas Numbers - GeeksforGeeks

Lucas numbers are similar to Fibonacci numbers. Lucas numbers are also defined as the sum of its two immediate previous terms. But here the first two terms are 2 and 1 where as in Fibonacci numbers the first two terms are 0 and 1 respectively.

Mathematically, Lucas Numbers may be defined as:

lucas

The Lucas numbers are in the following integer sequence:

2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123 …………..

Write a function int lucas(int n) n as argument and returns the n'th Lucas number.


Read full article from Lucas Numbers - GeeksforGeeks


XOR Cipher - GeeksforGeeks



XOR Cipher - GeeksforGeeks

XOR Encryption is an encryption method used to encrypt data and is hard to crack by brute-force method, i.e generating random encryption keys to match with the correct one.

Below is a simple implementation in C++. The concept of implementation is to first define a XOR – encryption key and then to perform XOR operation of the characters in the String with this key which you want to encrypt. To decrypt the encrypted characters we have to perform XOR operation again with the defined key. Here we are encrypting the entire String.


Read full article from XOR Cipher - GeeksforGeeks


Great West Interview Experience | Set 1 - GeeksforGeeks



Great West Interview Experience | Set 1 - GeeksforGeeks

First written round on hirepro platform they asked questions on Quants, verbal, logical and technical mcqs mainly c++ and Java, written was medium level not the easy one out of 500 they short listed some 250 for the second round that was GD round, they divide 250 in group of 15 each, GD was tougher one they gave us some 4-5 topics they fluctuate the topics in between, and out of 250 they only shortlisted 45 for the interviews round.
they were 2 interview rounds

1st round : Itwas technical round two people take this interview they asked questions related to C, C++, DBMS joins and some queries and also asked us to find the errors in the given code.
2nd round: It was panel interview round that was taken by all the 10 members who came for the recruitment in this 2-3 people asked us technical questions and remaining were looking at how we are behaving .


Read full article from Great West Interview Experience | Set 1 - GeeksforGeeks


Harshad Number - GeeksforGeeks



Harshad Number - GeeksforGeeks

An integer number in base 10 which is divisible by sum of it digits is said to be a Harshad Number. An n-harshad number is an integer number divisible by sum of its digit in base n.

Below are first few Harshad Numbers represented in base 10:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20………

Given a number in base 10, our task is to check if it is a Harshad Number or not.


Read full article from Harshad Number - GeeksforGeeks


Loop Unrolling - GeeksforGeeks



Loop Unrolling - GeeksforGeeks

Loop unrolling is a loop transformation technique that helps to optimize the execution time of a program. Loops with small number of iterations can be unrolled for higher performance. Loop unrolling aims to increase the program's speed by eliminating loop control instruction and loop test instructions.


Read full article from Loop Unrolling - GeeksforGeeks


4 Cool Amazon Price Tracking Tools -dealdump -



4 Cool Amazon Price Tracking Tools -dealdump -

In November 2012 the price was $400, and by December – Christmas time – it increased to $500, only to drop back to $400 in February. Obviously, Christmas time was a bad moment to buy this Samsung TV. The reasons for these price-changes can be anything: availability, popularity, competition, you name it. On the same chart, you also see that the price of this 32 inch TV has been going down ever since February and is at it's lowest point right now.

This is great information if you're about to do a big purchase: is the current price a normal price? Has it been going up? Has it been going down? What's going on here?


Read full article from 4 Cool Amazon Price Tracking Tools -dealdump -


Amazon Tips, Tricks And Tools To Ensure You Never Pay Too Much | The Huffington Post



Amazon Tips, Tricks And Tools To Ensure You Never Pay Too Much | The Huffington Post

Pardon the Ayn Rand-ian admonition, but studying historic prices on any product can help you avoid buying at an inopportune time. Just as the prices of airline tickets fluctuate based on the day of the week or time of year, so too do the prices of many other products. On a macro level, knowing prime buying seasons for your gear is key: Lifehacker has a handy list of the best time to purchase just about anything you can imagine. (Time to stock up on wine and children's clothes!)

Visualizing price changes over several days can be handy too, especially if you're looking to buy used and want to see what an item would customarily go for. There are a few ways to do this for Amazon products: Using a browser extension is probably easiest, and there are dozens to choose from, including The Tracktor and The Camelizer. I use the extension from Keepa.com, which shows you a simple line graph of your product's price history right beneath its basic information on Amazon.


Read full article from Amazon Tips, Tricks And Tools To Ensure You Never Pay Too Much | The Huffington Post


10 Gifts for Baby’s 1st Birthday!



10 Gifts for Baby's 1st Birthday!

Walking those aisles of baby toys, many of them claiming that they will teach babies important developmental skills…especially those toys we call "SCLANS" that focus on teaching kids about shapes, colors, letters, and numbers (learn more about a speech therapist's perspective on SCLANS here). How are we to know which toys are actually good for the little one who is transitioning from infancy to toddlerhood as they turn one year old?


Read full article from 10 Gifts for Baby's 1st Birthday!


Deep Learning with Apache Spark and TensorFlow - The Databricks Blog



Deep Learning with Apache Spark and TensorFlow - The Databricks Blog

Neural networks have seen spectacular progress during the last few years and they are now the state of the art in image recognition and automated translation.  TensorFlow is a new framework released by Google for numerical computations and neural networks. In this blog post, we are going to demonstrate how to use TensorFlow and Spark together to train and apply deep learning models.

You might be wondering: what's Apache Spark's use here when most high-performance deep learning implementations are single-node only? To answer this question, we walk through two use cases and explain how you can use Spark and a cluster of machines to improve deep learning pipelines with TensorFlow:

  1. Hyperparameter Tuning: use Spark to find the best set of hyperparameters for neural network training, leading to 10X reduction in training time and 34% lower error rate.
  2. Deploying models at scale: use Spark to apply a trained neural network model on a large amount of data.


Read full article from Deep Learning with Apache Spark and TensorFlow - The Databricks Blog


Collaborative Filtering - RDD-based API - Spark 2.0.2 Documentation



Collaborative Filtering - RDD-based API - Spark 2.0.2 Documentation

spark.mllib currently supports model-based collaborative filtering, in which users and products are described by a small set of latent factors that can be used to predict missing entries. spark.mllib uses the alternating least squares (ALS) algorithm to learn these latent factors. The implementation in spark.mllib has the following parameters: numBlocks is the number of blocks used to parallelize computation (set to -1 to auto-configure). rank is the number of latent factors in the model. iterations is the number of iterations of ALS to run. ALS typically converges to a reasonable solution in 20 iterations or less. lambda specifies the regularization parameter in ALS. implicitPrefs specifies whether to use the explicit feedback ALS variant or one adapted for implicit feedback data. alpha is a parameter applicable to the implicit feedback variant of ALS that governs the baseline confidence in preference observations. Explicit vs.

Read full article from Collaborative Filtering - RDD-based API - Spark 2.0.2 Documentation


British woman 'gang raped' in Dubai says "I'm petrified out here alone" after she's arrested for extra-marital sex - Mirror Online



British woman 'gang raped' in Dubai says "I'm petrified out here alone" after she's arrested for extra-marital sex - Mirror Online

British woman 'gang raped' in Dubai says "I'm petrified out here alone" after she's arrested for extra-marital sex Zara-Jayne Moisey, 25, from Widnes, has spoken about her "nightmare" and is facing jail in the Middle East after reporting that two men allegedly attacked her in a hotel  Share  Share + Subscribe Could not subscribe, try again laterInvalid Email A British woman facing jail for extra-marital sex after reporting an alleged gang rape on holiday in Dubai has told of her "nightmare" and said she's "petrified". Zara-Jayne Moisey, 25, told police in the United Arab Emirates she was violently raped by two British men in the city last month. But instead of being treated as a victim, Zara, from Widnes, who is single after splitting from her husband, was reportedly locked up on suspicion of extra-marital sex and later charged with the offence. Her passport has been confiscated and she now faces a trial, claim her family and friends.

Read full article from British woman 'gang raped' in Dubai says "I'm petrified out here alone" after she's arrested for extra-marital sex - Mirror Online


Top Toys for 1 YEAR OLD BOYS



Top Toys for 1 YEAR OLD BOYS


Read full article from Top Toys for 1 YEAR OLD BOYS


Best Gifts for One-Year-Olds | Parents



Best Gifts for One-Year-Olds | Parents

Best Gifts for One-Year-Olds Best Gifts for One-Year-Olds Your baby's gone from a little bean to a crawling, smiling, laughing in toddler in the last year. We've got the 12 presents that experts tell us are developmentally right for your child and cool for parents as well. By Lambeth Hochwald Shape Sorter Why she'll love it: Sorting shapes is trial and error at its most basic. Why experts love it: "Children work on hand-eye coordination and learn how objects with similar properties go together," says Joyce Nuner, PhD, assistant professor of child development and family studies at Baylor University in Waco, Texas. Our pick: This adorable wooden cow-shaped box looks like a folk art piece and comes with all the requisite shapes, so your kid gets a start at learning those too. Since the pieces are stored inside, he'll learn how to clean up when he's done. Nesting or Stacking Toy Why he'll love it:

Read full article from Best Gifts for One-Year-Olds | Parents


Top 20 Best Toddler Toys for 1 & 2 Year Olds | Heavy.com



Top 20 Best Toddler Toys for 1 & 2 Year Olds | Heavy.com

Published 11:14 am EST, September 28, 2015 9.5k Although they're too young to fully appreciate it, it's likely that you want to spoil your toddler. However, choosing great toddler toys for your 1 year old or 2 year old is especially tough nowadays. You have to worry about where your toys are coming from, how well-made they are, whether or not they have any small parts, and most importantly, if they'll keep your toddler amused (I can't tell you how many times I've purchased a brand new toy for my little ones that they just played with for 10 minutes and never touched again). You won't find any of these on our hot new toys of 2015 list, as those are mostly for older kids. No, instead, this list is solely for the younger ones. But, luckily for you, we're here to help. Here are the top 20 best toddler toys to buy: 1. Fisher-Price Bright Beats Dance & Move BeatBo Get your little one up and dancing with the Fisher-Price Bright Beats Dance and Move Beatbo . This little guy,

Read full article from Top 20 Best Toddler Toys for 1 & 2 Year Olds | Heavy.com


求一个整数stream的sum, avg, median - 西施豆腐渣 - 博客频道 - CSDN.NET



求一个整数stream的sum, avg, median - 西施豆腐渣 - 博客频道 - CSDN.NET

好久没更新了, 上个新题吧。 求一个整数stream的sum, avg, median。 数据不断流入, 随时求sum, avg, median


Read full article from 求一个整数stream的sum, avg, median - 西施豆腐渣 - 博客频道 - CSDN.NET


Trump advisor takes issue with Silicon Valley's Asian CEOs



Trump advisor takes issue with Silicon Valley's Asian CEOs

20m ago 37m ago 44m ago 51m ago Trump advisor takes issue with Silicon Valley's Asian CEOs More than that, chief strategist Steve Bannon's claim isn't based on fact, either. Carlo Allegri / Reuters Before President-elect Donald Trump's chief strategist Stephen Bannon was headed to the White House, he was running " platform for the alt-right " website Breitbart News. Aside from overseeing the publication of anti-Semitic and misogynistic articles, Bannon also hosted the site's Sirius XM radio show. A segment from November 5th, 2015 that featured an interview with Trump has resurfaced thanks to The Washington Post . Mostly, it covers stuff like campaign financing, but at around the 16:23 mark, talk goes to H-1B visas for skilled workers to help keep them in the country after graduating from college. In response to Trump actually arguing that we need to keep some immigrants in the country, Bannon says,

Read full article from Trump advisor takes issue with Silicon Valley's Asian CEOs


LeetCode 446. Arithmetic Slices II - Subsequence | 行走的轮子



LeetCode 446. Arithmetic Slices II - Subsequence | 行走的轮子

A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.

For example, these are arithmetic sequences:

1, 3, 5, 7, 9
7, 7, 7, 7
3, -1, -5, -9
The following sequence is not arithmetic.

1, 1, 2, 5, 7

A zero-indexed array A consisting of N numbers is given. A subsequence slice of that array is any sequence of integers (P0, P1, …, Pk) such that 0 ≤ P0 < P1 < … < Pk < N.

A subsequence slice (P0, P1, …, Pk) of array A is called arithmetic if the sequence A[P0], A[P1], …, A[Pk-1], A[Pk] is arithmetic. In particular, this means that k ≥ 2.

The function should return the number of arithmetic subsequence slices in the array A.

The input contains N integers. Every integer is in the range of -231 and 231-1 and 0 ≤ N ≤ 1000. The output is guaranteed to be less than 231-1.

Example:

Input: [2, 4, 6, 8, 10]

Output: 7

Explanation:
All arithmetic subsequence slices are:
[2,4,6]
[4,6,8]
[6,8,10]
[2,4,6,8]
[4,6,8,10]
[2,4,6,8,10]
[2,6,10]
Subscribe to see which companies asked this question

题意解析

这道题的含义就是找出数列中所有3个数以上的等差数列的数量。

解法分析

使用动态规划来解这道题。假设dp[i][j]表示以A[i]结尾的子序列(P0, P1, …, Pi)构成的数列,序列中的元素之差为j。而dp[i][j]=dp[k][j]>0?dp[k][j]+1:1,0<=i<A.length(),0<=k<i。其中dp[k][j]为0的时候需要加1,也就是仅存在两个数的数列时dp[i][j]需要加1,这是因为再之后第3个数匹配时可以形成一个正确数列,然后1加到总数里。


Read full article from LeetCode 446. Arithmetic Slices II - Subsequence | 行走的轮子


LeetCode 452. Minimum Number of Arrows to Burst Balloons – Shell32



LeetCode 452. Minimum Number of Arrows to Burst Balloons – Shell32

There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter and hence the x-coordinates of start and end of the diameter suffice. Start is always smaller than end. There will be at most 104 balloons.
An arrow can be shot up exactly vertically from different points along the x-axis. A balloon with xstart and xend bursts by an arrow shot at x if xstart ≤ x ≤ xend. There is no limit to the number of arrows that can be shot. An arrow once shot keeps travelling up infinitely. The problem is to find the minimum number of arrows that must be shot to burst all balloons.
Example:

基本思路是每次尽可能多的刺破气球, 所以一开始从最左边的气球的右边缘发射一支箭, 否则最左边的气球就无法刺破了, 这样也能保证刺破尽可能多的气球.

但是问题在于如何判断哪个气球在"最左边", 不能以左边缘来进行判断, 因为有这种情况: (1,10),(2,5), 第一支箭应该从x=5发出而不是x=10, 所以排序时应该使用每个气球的右边缘来进行排序.


Read full article from LeetCode 452. Minimum Number of Arrows to Burst Balloons – Shell32


Counts of distinct consecutive sub-string of length two using C++ STL - GeeksforGeeks



Counts of distinct consecutive sub-string of length two using C++ STL - GeeksforGeeks

Given a string the task is to print all distinct sub-strings of length two in the given string. All substrings should be printed in lexicographical order.

Examples:

Input: str = "abcab"  Output: ab-2          bc-1          ca-1    Input: str = "xyz"  Output: xy-1          yz-1  

We strongly recommend you to minimize your browser and try this yourself first.

The idea of this article is to demonstrate map and pair in C++ STL.

We declare a map d_pairs that uses a character pair key and count as value. We iterate over the given string from the starting index to store every consecutive pair if not present already and increment its count in the map. After completion of the loop, we get all distinct consecutive pairs and their corresponding occurrence count in the map container.

Please note that map is used as we need output in sorted order. We could use a unordered_map() if output was not needed in sorted order. Time complexity of underdered_map() operations is O(1) while that of map is O(Log n)


Read full article from Counts of distinct consecutive sub-string of length two using C++ STL - GeeksforGeeks


3 reasons why you're not hired. ~ Josh Kemp



3 reasons why you're not hired. ~ Josh Kemp

Don't have good people skills:
Only 50% of getting hired for an entry level tech position is technical ability.  The other 50% is people skills and knowing how to market yourself.  The best birthday gift I ever receiveed was a used worn out copy of "How to Win Friends and Influence People" by Dale Carnegie.  My Aunt gave me the book and 1 stick of Wrigleys chewing gum for my 14th birthday.  I guess I was a rude bad breathed teenager :-)  That book changed my life, I always get compliments about my ability to connect with people.  How can you nail interviews if you can't connect with people or you come across as rude?  What's the sweetest sound to any person?  hint: it's in the book ( and no I don't get any kickbacks )


Don't know how to sell yourself:
I learned this skill from listening to an interview of Robert Kiyosaki.  He talked about how he wasn't a great writer, but he was a best selling author!  He made it very clear that he wasn't going to ever challenge the great works of fiction.  He talked about how important it is to understand selling, if you ever want to make serious money.  I am always shocked by how many technical people are way under payed.  I have worked with senior level architects for test automation that were just terrible, yet highly paid.  On the flip side I know many talented and skilled developers who make far below what they are worth.  If you don't learn to sell yourself and abilities, you won't be able to nail interviews or even get interviews in the first place.

Read full article from 3 reasons why you're not hired. ~ Josh Kemp


CDN Caching Problems - The "Vary: User-Agent" Header | ./orcaman



CDN Caching Problems - The "Vary: User-Agent" Header | ./orcaman

If you accidentally send the header and you are using a CDN, you can expect to experience the following nasty problems:
1. Your server load will increase dramatically, since requests will hit the origin instead of getting the content from the CDN.
2. Your users will experience slower response times because your origin will have to recomptue the file's content on every request, and the Geo-based content delivery will not be activated (the request will have to reach your origin server anyway).
3. Your CDN bill might explode (the CDN's usually charge by bandwidth, and they will be serving a lot more content if they are not able to cache it).

Read full article from CDN Caching Problems - The "Vary: User-Agent" Header | ./orcaman


独角兽风光不再 硅谷人才求稳转投传统上市公司_网易科技



独角兽风光不再 硅谷人才求稳转投传统上市公司_网易科技

在线食品外卖服务商GrubHub也是如此。今年1月份公司跌至历史地位,当时不少同业初创公司也在抢占市场份额。但GrubHub并没有倒下。相比之下,很多初创企业却面临着越来越多的商业模式问题,在高估值下募集资金也越发困难。

GrubHub首席执行官马特·马洛尼(Matt Maloney)指出,"这是皇帝的新装。这些初创公司的存在的确影响了我们的市值。但目前基本上已经消失。"

市场研究公司Canaccord Genuity的分析师在写给投资者的报告中指出,GrubHub的直觉开始从"惧怕独角兽"开始转变到认识了规模经济的好处。这也有助于解释GrubHub目前的股价已经从2016年低点翻了一番。

独角兽企业面临的困境,也有助于很多传统公司业务量的上涨。今年早些时候,人力资源创业公司Zenefits更换了首席执行官,又违反了保险许可规则。传统人力资源公司Paychex首席执行官马丁·穆奇(Martin Mucci)在接受采访时指出,这推动了传统的人力资源业务。


Read full article from 独角兽风光不再 硅谷人才求稳转投传统上市公司_网易科技


How to Setup a Highly Available Multi-AZ Cassandra Cluster on AWS EC2 - High Scalability -



How to Setup a Highly Available Multi-AZ Cassandra Cluster on AWS EC2 - High Scalability -

Originally built by Facebook in 2009, Apache Cassandra is a free and open-source distributed database designed to handle large amounts of data across a large number of servers. At Stream, we use Cassandra as the primary data store for our feeds. Cassandra stands out because it's able to:

  • Shard data automatically

  • Handle partial outages without data loss or downtime

  • Scales close to linearly

If you're already using Cassandra, your cluster is likely configured to handle the loss of 1 or 2 nodes. However, what happens when a full availability zone goes down?

In this article you will learn how to setup Cassandra to survive a full availability zone outage. Afterwards, we will analyze how moving from a single to a multi availability zone cluster impacts availability, cost, and performance.


Read full article from How to Setup a Highly Available Multi-AZ Cassandra Cluster on AWS EC2 - High Scalability -


Why Redis beats Memcached for caching | InfoWorld



Why Redis beats Memcached for caching | InfoWorld

Using Redis data structures can simplify and optimize several tasks -- not only while caching, but even when you want the data to be persistent and always available. For example, instead of storing objects as serialized strings, developers can use a Redis Hash to store an object's fields and values, and manage them using a single key. Redis Hash saves developers the need to fetch the entire string, deserialize it, update a value, reserialize the object, and replace the entire string in the cache with its new value for every trivial update -- that means lower resource consumption and increased performance.

Other data structures offered by Redis (such as lists, sets, sorted sets, hyperloglogs, bitmaps, and geospatial indexes) can be used to implement even more complex scenarios. Sorted sets for time-series data ingestion and analysis is another example of a Redis data structure that offers enormously reduced complexity and lower bandwidth consumption.

Another important advantage of Redis is that the data it stores isn't opaque, so the server can manipulate it directly. A considerable share of the 180-plus commands available in Redis are devoted to data processing operations and embedding logic in the data store itself via server-side Lua scripting. These built-in commands and user scripts give you the flexibility of handling data processing tasks directly in Redis without having to ship data across the network to another system for processing.

Redis offers optional and tunable data persistence designed to bootstrap the cache after a planned shutdown or an unplanned failure. While we tend to regard the data in caches as volatile and transient, persisting data to disk can be quite valuable in caching scenarios. Having the cache's data available for loading immediately after restart allows for much shorter cache warm-up and removes the load involved in repopulating and recalculating cache contents from the primary data store.


Read full article from Why Redis beats Memcached for caching | InfoWorld


LSM Tree存储组织结构介绍 - bangerlee - 博客园



LSM Tree存储组织结构介绍 - bangerlee - 博客园

LSM Tree(Log Structured Merge Trees)数据组织方式被应用于多种数据库,如LevelDB、HBase、Cassandra等,下面我们从为什么使用LSM tree、LSM tree的实现思路两方面介绍这种存储组织结构,完成对LSM tree的初步了解。

 

存储背景回顾

LSM tree相较B+树或其他索引存储实现方式,提供了更好的写性能。究其原因,我们先回顾磁盘相关的一点背景知识。

 

顺序操作磁盘的性能,较随机读写磁盘的性能高很多,我们实现数据库时,也是围绕磁盘的这点特性进行设计与优化。如果让写性能最优,最佳的实现方式就是日志型(Log/Journal)数据库,其以追加(Append)的方式写磁盘文件。

 

有得即有舍,万事万物存在权衡,带来最优写性能的同时,单纯的日志数据库读性能很差,为找到一条数据,不得不遍历数据记录,要实现范围查询(range)几乎不可能。为优化日志型数据库的读性能,实际应用中通常结合以下几种优化措施:

二分查找(Binary Search): 在一个数据文件中使用二分查找加速数据查找

哈希(Hash): 写入时通过哈希函数将数据放入不同的桶中,读取时通过哈希索引直接读取

B+树: 使用B+树作为数据组织存储形式,保持数据稳定有序

外部索引文件: 除数据本身按日志形式存储外,另对其单独建立索引加速读取

 

以上措施都很大程度提升了读性能(如二分查找将时间复杂度提升至O(log(N))),但相应写性能也有折损,第一写数据时需要维护索引,这视索引的实现方式,最差情况下可能涉及随机的IO操作;第二如果用B+树等结构组织数据,写入涉及两次IO操作,先要将数据读出来再写入。

 

LSM Tree存储结构

LSM tree存储实现思路与以上四种措施不太相同,其将随机写转化为顺序写,尽量保持日志型数据库的写性能优势,并提供相对较好的读性能。具体实现方式如下:

1. 当有写操作(或update操作)时,写入位于内存的buffer,内存中通过某种数据结构(如skiplist)保持key有序

2. 一般的实现也会将数据追加写到磁盘Log文件,以备必要时恢复

3. 内存中的数据定时或按固定大小地刷到磁盘,更新操作只不断地写到内存,并不更新磁盘上已有文件

4. 随着越来越多写操作,磁盘上积累的文件也越来越多,这些文件不可写且有序

5. 定时对文件进行合并操作(compaction),消除冗余数据,减少文件数量

 

以上过程用图表示如下:

LSM Tree存储结构的写操作,只需更新内存,内存中的数据以块数据形式刷到磁盘,是顺序的IO操作,另外磁盘文件定期的合并操作,也将带来磁盘IO操作。

LSM tree存储结构的读操作,先从内存数据开始访问,如果在内存中访问不到,再顺序从一个个磁盘文件中查找,由于文件本身有序,并且定期的合并减少了磁盘文件个数,因而查找过程相对较快速。

 

合并操作是LSM tree实现中重要的一环,LevelDB、Cassandra中,使用基于层级的合并方式(Levelled compaction),生成第N层的时候,对N-1层的数据进行排序,使得每层内的数据文件之间都是有序的,但最高层除外,因为该层不断有数据文件产生,因而只是数据文件内部按key有序。

 

除最高层外,其他层文件间数据有序,这也加速了读过程,因为一个key对应的value只存在一个文件中。假设总共有N层,每层最多K个数据文件,最差的情况下,读操作先遍历K个文件,再遍历每层,共需要K+(N-1)次读盘操作。

 

总结

LSM tree存储框架实现的思路较简单,其先在内存中保存数据,再定时刷到磁盘,实现顺序IO操作,通过定期合并文件减少数据冗余;文件有序,保证读取操作相对快速。

我们需要结合实际的业务场景选择合适的存储实现,不存在万金油式的通用存储框架。LSM tree适用于写多、读相对少(或较多读取最新写入的数据,该部分数据存在内存中,不需要磁盘IO操作)的业务场景。


Read full article from LSM Tree存储组织结构介绍 - bangerlee - 博客园


Snapchat面经(师兄的) - neverlandly - 博客园



Snapchat面经(师兄的) - neverlandly - 博客园

给一个LinkedList环,给其中任一个节点的reference,求删去LinkedList中所有value=k的点

我的想法:假设给定的点事ListNode oneNode, 设置ListNode dummy = new ListNode(-1);

dummy.next = oneNode

然后扫描一次找到环里最后一个点,断链:ListNode end.next = null;

然后就开始扫描,删点

然后再扫描一次,将最后一个点.next指向开头


Read full article from Snapchat面经(师兄的) - neverlandly - 博客园


Java Thread Priority in Multithreading - GeeksforGeeks



Java Thread Priority in Multithreading - GeeksforGeeks

In a Multi threading environment, thread scheduler assigns processor to a thread based on priority of thread. Whenever we create a thread in Java, it always has some priority assigned to it. Priority can either be given by JVM while creating the thread or it can be given by programmer explicitly.
Accepted value of priority for a thread is in range of 1 to 10. There are 3 static variables defined in Thread class for priority.

public static int MIN_PRIORITY: This is minimum priority that a thread can have. Value for this is 1.
public static int NORM_PRIORITY: This is default priority of a thread if do not explicitly define it. Value for this is 5.
public static int MAX_PRIORITY: This is maximum priority of a thread. Value for this is 10.

Get and Set Thread Priority:

  1. public final int getPriority(): java.lang.Thread.getPriority() method returns priority of given thread.
  2. public final void setPriority(int newPriority): java.lang.Thread.setPriority() method changes the priority of thread to the value newPriority. This method throws IllegalArgumentException if value of parameter newPriority goes beyond minimum(1) and maximum(10) limit.


Read full article from Java Thread Priority in Multithreading - GeeksforGeeks


Useful CMD commands for daily use in Windows OS - GeeksforGeeks



Useful CMD commands for daily use in Windows OS - GeeksforGeeks

List of uncommon useful cmd commands are as follows:

  1. Cipher:
    Cipher.exe is a built-in command line tool in the Windows operating system that can be used to encrypt or decrypt data on NTFS drives. This tool also lets to securely delete data by overwriting it.
    Cipher Switches:

    • /? : Displays help at the command prompt.
    • /e : Encrypts the specified folders. Folders are marked so that files that are added to the folder later are encrypted too.
    • /d : Decrypts the specified folders. Folders are marked so that files that are added to the folder later are encrypted too.
    • /w : PathName – Removes data on unused portions of a volume. PathName can indicate any directory on the desired volume.

    Syntax:

     cipher /w:c 

    This will wipe free space on the drive. The command does not overwrite undeleted data, so you will not wipe out files you need by running this command.

  2. File compare:
    File compare (or fc) is a great command line tool that can be used to compare files to see if there are any content or binary code differences that you can access if you are using a PC. It is a simple program that will compare the contents of text or binary files and is capable of comparing both ASCII and Unicode text. You can use this tool to display any lines from two files or two sets of files that do not match up with the others.
    Switches:

    • /b – This switch will perform a binary comparison.
    • /c – If you need to do a case insensitive comparison, use this switch.
    • /a – This switch will make FC show only the first and last lines for each group of differences.
    • /u – Use this switch to compare files as Unicode text files.
    • /l – This will compare your files as ASCII text.
    • /n – This switch can only be used with ASCII but it will show all the corresponding line numbers.

    Syntax:
    Simply type "fc" and then the directory path and file name of the two files you want to compare.


Read full article from Useful CMD commands for daily use in Windows OS - GeeksforGeeks


Check if a string can become empty by recursively deleting a given sub-string - GeeksforGeeks



Check if a string can become empty by recursively deleting a given sub-string - GeeksforGeeks

Given a string "str" and another string "sub_str". We are allowed to delete "sub_str" from "str" any number of times. It is also given that the "sub_str" appears only once at a time. The task is to find if "str" can become empty by removing "sub_str" again and again.

Examples:

Input  : str = "GEEGEEKSKS", sub_str = "GEEKS"  Output : Yes  Explanation : In the string GEEGEEKSKS, we can first                 delete the substring GEEKS from position 4.                The new string now becomes GEEKS. We can                 again delete sub-string GEEKS from position 1.                 Now the string becomes empty.      Input  : str = "GEEGEEKSSGEK", sub_str = "GEEKS"  Output : No  Explanation : In the string it is not possible to make the                string empty in any possible manner.  

We strongly recommend you to minimize your browser and try this yourself first.

A simple solution to solve this problem is by using inbuilt string functions find() and erase(). First input the sub-string substr for searching purpose in the original string str, then iterate the original string to find the index of sub-string using find() which return starting index of the sub-string in the original string else -1 if not found and erase that sub-string using erase() until length of original string is greater than 0.

The above simple solutions works because the given substring appears only once at a time.


Read full article from Check if a string can become empty by recursively deleting a given sub-string - GeeksforGeeks


New in Spring 5: Functional Web Framework



New in Spring 5: Functional Web Framework

September 22, 2016 As mentioned yesterday in Juergen's blog post , the second milestone of Spring Framework 5.0 introduced a new functional web framework. In this post, I will give more information about the framework. Keep in mind the functional web framework is built on the same reactive foundation that we provided in M1 and on which we also support annotation-based (i.e. @Controller @RequestMapping ) request handling, see the M1 blog post for more on that. Example We start with some excerpts from our sample application . Below is a reactive repository that exposes Person objects. It is quite similar to a traditional, non-reactive repository, except that it returns Flux List traditionally, and Mono Person Mono is used as a completion signal: to indicate when the save has been completed. For more information on these Reactor types, refer to Dave's blog post . public interface PersonRepository { Mono getPerson(int id); Flux allPeople();

Read full article from New in Spring 5: Functional Web Framework


How Spring 3.1 Environments & Profiles will make your life better! | Developed



How Spring 3.1 Environments & Profiles will make your life better! | Developed

My goal of writing one technical blog post per week fell to the wayside around December mainly due to work related project time constraints. I have a four-day weekend and a sparkling new home office, which has to be used for something other than surfing hacker news. Its noon here and I have two hours to produce this blog post so here I go!

The software I write or design generally needs to be deployed in different configurations. These deployment configuration end points can be generalised into the following buckets

  1. Java Enterprise Containers (jboss, weblogic, tomcat, glassfish, etc)
  2. Standalone Java application
  3. GUI Applications
  4. Testing Frameworks

Ignoring GUI Applications for the moment (I might return to these later) the code is often the same between container, standalone and testing. This leads to a key design consideration or philosophy when designing and coding this "type" of software. The code I write needs to run perfectly and untainted in each scenario.

That's crucial to quality and robustness! The problem is that there are environmentally aware resources that are configured depending on where the code is executed. When I am writing a unit test I will not (I know I could, but I think you are missing the point) have my datasource bound to a JNDI tree. Where as in the container I simple lookup the tree and ask can I have a datasource please.


Read full article from How Spring 3.1 Environments & Profiles will make your life better! | Developed


How to set development/test/production environment in spring project (XML) | Code Breeze !



How to set development/test/production environment in spring project (XML) | Code Breeze !

In real life development, a project always need different sets of  configurations for development, system test and production environments. Most common variables in these different environments are database location or jms location.

If the project uses spring and will not run in any container, the spring profiles can be used to make your life easier when switching environments. This article demonstrates the best practice to do so in my experiences to achieve these goals:

  1. Finally there will be only one packaged jar for all different environment
  2. The same jar can run in development environment by giving option  "-Dspring.profiles.active=development" to JVM
  3. The same jar can run in test environment by giving option  "-Dspring.profiles.active=test" to JVM
  4. The same jar can run in production environment without options to JVM
  5. The JUnit test cases can easily switch between different environments

If your project will run within web containers, should use JNDI to define the resources and inject resources into Java code.

The basic idea is put property variables in 3 different property files, namely development.properties/test.properties/production.properties, then use the proper file for different environment ( spring active profile).


Read full article from How to set development/test/production environment in spring project (XML) | Code Breeze !


San Francisco voters reject sales tax, approves spending measures | KRON4.com



San Francisco voters reject sales tax, approves spending measures | KRON4.com

By Bay City News Published: November 9, 2016, 8:08 am Updated: SAN FRANCISCO (BCN) — San Francisco voters proved eager on Tuesday to support several budget set-asides for street trees, homelessness, transportation and services for seniors and the disabled, but were unwilling to approve a sales tax intended to pay for some of those services. Proposition E, which would transfer responsibility for street tree maintenance from property owners to the city, and require the city to set aside $19 million a year to pay for their upkeep, passed with a resounding 78.9 percent of the vote. Likewise Proposition S, which directs that city hotel tax funds be allocated toward arts programs and family homeless services, passed with 62.8 percent of the vote. Proposition I, which creates a "Dignity Fund" for services for seniors and adults with disabilities and requires the city to set aside at least $38 million a year for them, passed with 66.36 percent of the vote. Supervisor Eric Mar,

Read full article from San Francisco voters reject sales tax, approves spending measures | KRON4.com


[LeetCode] Valid Word Square 验证单词平方 - Grandyang - 博客园



[LeetCode] Valid Word Square 验证单词平方 - Grandyang - 博客园

Given a sequence of words, check whether it forms a valid word square.

A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤k < max(numRows, numColumns).

Note:

  1. The number of words given is at least 1 and does not exceed 500.
  2. Word length will be at least 1 and does not exceed 500.
  3. Each word contains only lowercase English alphabet a-z.

 

Example 1:

Input: [   "abcd",   "bnrt",   "crmy",   "dtye" ]  Output: true  Explanation: The first row and first column both read "abcd". The second row and second column both read "bnrt". The third row and third column both read "crmy". The fourth row and fourth column both read "dtye".  Therefore, it is a valid word square. 

 

Example 2:

Input: [   "abcd",   "bnrt",   "crm",   "dt" ]  Output: true  Explanation: The first row and first column both read "abcd". The second row and second column both read "bnrt". The third row and third column both read "crm". The fourth row and fourth column both read "dt".  Therefore, it is a valid word square. 

 

Example 3:

Input: [   "ball",   "area",   "read",   "lady" ]  Output: false  Explanation: The third row reads "read" while the third column reads "lead".  Therefore, it is NOT a valid word square.

 

这道题给了我们一个二位数组,每行每列都是一个单词,需要满足第k行的单词和第k列的单词要相等,这里不要求每一个单词的长度都一样,只要对应位置的单词一样即可。那么这里实际上也就是一个遍历二维数组,然后验证对应位上的字符是否相等的问题,由于各行的单词长度不一定相等,所以我们在找对应位置的字符时,要先判断是否越界,即对应位置是否有字符存在,遇到不符合要求的地方直接返回false,全部遍历结束后返回true,参见代码如下:


Read full article from [LeetCode] Valid Word Square 验证单词平方 - Grandyang - 博客园


What is the Difference Between 127.0.0.1 and 0.0.0.0?



What is the Difference Between 127.0.0.1 and 0.0.0.0?

What is the Difference Between 127.0.0.1 and 0.0.0.0?

  • 127.0.0.1 is the loopback address (also known as localhost).
  • 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown, or non-applicable target (a 'no particular address' place holder).

In the context of a route entry, it usually means the default route.

In the context of servers, 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.


Read full article from What is the Difference Between 127.0.0.1 and 0.0.0.0?


connection problem with cassandra - Stack Overflow



connection problem with cassandra - Stack Overflow

This has "nothing" to do with cassandra.

The documentation (regarding NoRouteToHostException) states that:

"Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the remote host cannot be reached because of an intervening firewall, or if an intermediate router is down. "


Read full article from connection problem with cassandra - Stack Overflow


[LeetCode] Arranging Coins 排列硬币 - Grandyang - 博客园



[LeetCode] Arranging Coins 排列硬币 - Grandyang - 博客园

You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.

Given n, find the total number of full staircase rows that can be formed.

n is a non-negative integer and fits within the range of a 32-bit signed integer.

Example 1:

n = 5  The coins can form the following rows: ¤ ¤ ¤ ¤ ¤  Because the 3rd row is incomplete, we return 2. 

Example 2:

n = 8  The coins can form the following rows: ¤ ¤ ¤ ¤ ¤ ¤ ¤ ¤  Because the 4th row is incomplete, we return 3. 

 

这道题给了我们n个硬币,让我们按一定规律排列,第一行放1个,第二行放2个,以此类推,问我们有多少行能放满。通过分析题目中的例子可以得知最后一行只有两种情况,放满和没放满。由于是按等差数列排放的,我们可以快速计算出前i行的硬币总数。我们先来看一种O(n)的方法,非常简单粗暴,就是从第一行开始,一行一行的从n中减去,如果此时剩余的硬币没法满足下一行需要的硬币数了,我们之间返回当前行数即可,参见代码如下:


Read full article from [LeetCode] Arranging Coins 排列硬币 - Grandyang - 博客园


程序员10月书讯 - 图灵教育 - 博客频道 - CSDN.NET



程序员10月书讯 - 图灵教育 - 博客频道 - CSDN.NET

好书需要大家推荐,在图灵书讯中选出你认为值得推荐的好书加推荐理由或推荐语,在文末评论里回复。下期书讯更新时,会在本期的书讯评论中选出若干优秀评论,获奖者可任选图灵书讯中的图书一本。

本月13本书,涉及方方面面,包括JavaPython、C#、JS、Swift、Haskell等编程语言相关图书、安全经典、用户体验与品牌塑造、数学经典著作等,所有小伙伴都能找到自己喜欢的Style。

1.《HTTPS权威指南:在服务器和Web应用上部署SSL/TLS和PKI》【含社区电子版】
2.《挑战程序设计竞赛2:算法数据结构
3.《魔力Haskell》
4.《spring Boot实战》【含社区电子版】
5.《Python网络编程(第3版)》
6.《C#经典实例(第4版)》
7.《精通JavaScript(第2版) 》
8.《精通Swift设计模式》
9.《社会工程:防范钓鱼欺诈(卷3)》
10.《速度与激情:以网站性能提升用户体验》【含社区电子版】
11.《精益品牌塑造》【含社区电子版】
12.《线性代数应该这样学(第3版)》
13.《数学悖论与三次数学危机》


Read full article from 程序员10月书讯 - 图灵教育 - 博客频道 - CSDN.NET


LeetCode 436. Find Right Interval – Shell32



LeetCode 436. Find Right Interval – Shell32

Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is on the "right" of i.

For any interval i, you need to store the minimum interval j's index, which means that the interval j has the minimum start point to build the "right" relationship for interval i. If the interval j doesn't exist, store -1 for the interval i. Finally, you need output the stored value of each interval as an array.

Note:

  1. You may assume the interval's end point is always bigger than its start point.
  2. You may assume none of these intervals have the same start point.


Read full article from LeetCode 436. Find Right Interval – Shell32


Next lexicographical string - PrismoSkills



Next lexicographical string - PrismoSkills

Problem: Write code to print the lexicographical next string for a given string.

(As in dictionary, next word after this word but having similar letters) For ex:

i/p abcd

o/p abdc


i/p abcged

o/p abdceg


Solution:

Find the number of characters at the end of string that are sorted

decreasingly e.g. in "abcgda" the length of such sub-string is 3 ( "gda" ).

Then look at the char before this sub-string (here it is 'c' ).

This character must be replaced with the smallest character in

the decreasing sub-sequence which is bigger than this char (here it's 'd').

Then sort the decreasing sub-string to be increasing


So the next lexicographical string of "abcgda" is "abdacg" ('d' is replaced

with 'c' and then "gca" is sorted to be "acg")

Note If a string is sorted decreasingly like "dcba" it's next char does

not exist so it's next string doesn't exist


Read full article from Next lexicographical string - PrismoSkills


Labels

Algorithm (219) Lucene (130) LeetCode (97) Database (36) Data Structure (33) text mining (28) Solr (27) java (27) Mathematical Algorithm (26) Difficult Algorithm (25) Logic Thinking (23) Puzzles (23) Bit Algorithms (22) Math (21) List (20) Dynamic Programming (19) Linux (19) Tree (18) Machine Learning (15) EPI (11) Queue (11) Smart Algorithm (11) Operating System (9) Java Basic (8) Recursive Algorithm (8) Stack (8) Eclipse (7) Scala (7) Tika (7) J2EE (6) Monitoring (6) Trie (6) Concurrency (5) Geometry Algorithm (5) Greedy Algorithm (5) Mahout (5) MySQL (5) xpost (5) C (4) Interview (4) Vi (4) regular expression (4) to-do (4) C++ (3) Chrome (3) Divide and Conquer (3) Graph Algorithm (3) Permutation (3) Powershell (3) Random (3) Segment Tree (3) UIMA (3) Union-Find (3) Video (3) Virtualization (3) Windows (3) XML (3) Advanced Data Structure (2) Android (2) Bash (2) Classic Algorithm (2) Debugging (2) Design Pattern (2) Google (2) Hadoop (2) Java Collections (2) Markov Chains (2) Probabilities (2) Shell (2) Site (2) Web Development (2) Workplace (2) angularjs (2) .Net (1) Amazon Interview (1) Android Studio (1) Array (1) Boilerpipe (1) Book Notes (1) ChromeOS (1) Chromebook (1) Codility (1) Desgin (1) Design (1) Divide and Conqure (1) GAE (1) Google Interview (1) Great Stuff (1) Hash (1) High Tech Companies (1) Improving (1) LifeTips (1) Maven (1) Network (1) Performance (1) Programming (1) Resources (1) Sampling (1) Sed (1) Smart Thinking (1) Sort (1) Spark (1) Stanford NLP (1) System Design (1) Trove (1) VIP (1) tools (1)

Popular Posts