five-essential-phone-screen-questions - steveyegge2



five-essential-phone-screen-questions - steveyegge2

I've been on a lot of SDE interview loops lately where the candidate failed miserably: not-inclined votes all around, even from the phone screeners who brought the person in initially.

It's usually pretty obvious when the candidate should have been eliminated during the phone screens. Well, it's obvious in retrospect, anyway: during the interviews, we find some horrible flaw in the candidate which, had anyone thought to ask about it during the phone screen, would surely have disqualified the person.

But we didn't ask. So the candidate came in for interviews and wound up wasting everyone's time.

Antipatterns

I've done informal postmortems on at least a hundred phone screens, many of them my own. Whenever a candidate bombs the interviews, I want to know what went wrong with the screen. And guess what? A pattern has emerged. Two patterns, actually.

The first pattern is that for most failed phone screens, the candidate did most of the talking. The screener only asked about stuff on the candidate's resume, and the candidate was able to talk with passion and enthusiasm about this incredibly cool thing they did, blah blah blah, and the screener was duly impressed.


Read full article from five-essential-phone-screen-questions - steveyegge2


Java quirks and interview gotchas | Dan Dreams of Coding



Java quirks and interview gotchas | Dan Dreams of Coding

Interviewers are a diverse lot. Some care about this, others about that, each has her own set of biases, and short of being perfect, there's really no way to please everyone. The worst is when you're doing well, then get hung up on an obscure language feature that the interviewer decides is make-or-break. This says more about the interviewer than you, but it can easily cost you an offer if you blank or aren't prepared.

So, as a public service announcement, and in the interests of moving the conversation past some of the annoying gotcha questions, here's a grab bag of things you should know about Java – some more important, some less so, some just plain annoying. But, well, interviews.


Read full article from Java quirks and interview gotchas | Dan Dreams of Coding


Closing shop | Dan Dreams of Coding



Closing shop | Dan Dreams of Coding

As for what comes next, looking for a job is a stressful, interesting, time-consuming, frustrating, exciting process. It isn't often that you get to decide how you're going to spend the next couple years of your life, and it's tempting to jump at an early offer, or to dismiss things too quickly. You're simultaneously trying to optimize for growth, impact, happiness, pay, and credential, but it's impossible to know if you've already seen the best option, if there's hidden crazy behind the friendly smiles, or if something better's out there.


Read full article from Closing shop | Dan Dreams of Coding


How Good an Estimator Are You?



How Good an Estimator Are You?

Chapter 2 of Software Estimation: Demystifying the Black Art opens with a quiz designed to test your estimation abilities. It's an interesting exercise, so I thought everyone might like to give it a shot.

  • For each question, fill in the upper and lower bounds so that you have a 90 percent chance of including the correct value.
  • Don't make your ranges too narrow or too wide, but be sure they're wide enough to give you a 90 percent chance of hitting the correct value.
  • Don't research the answers on the internet.
  • You must provide an estimate range for each question.
  • Spend no more than 10 minutes on this quiz.

So, how good an estimator are you?


Read full article from How Good an Estimator Are You?


Hilarious 'Facts' About Google's Baddest Engineer, Jeff Dean



Hilarious 'Facts' About Google's Baddest Engineer, Jeff Dean

Jeff Dean is one of Google's most popular engineers, ever.

The software genius is widely credited by Googlers for the blazing speed of the company's famed search engine. 

Dean has been with Google since 1999 and his engineering prowess and popularity have inspired "Jeff Dean Facts".


Read full article from Hilarious 'Facts' About Google's Baddest Engineer, Jeff Dean


GOP Senator Goes on Epic Anti-Trump Rant When Asked Why He Hasn’t Endorsed Yet | Mediaite



GOP Senator Goes on Epic Anti-Trump Rant When Asked Why He Hasn't Endorsed Yet | Mediaite

Lee responded by making it perfectly clear why he wasn't: "We can get into that if you want. We can get into the fact that he accused my best friend's father of conspiring to kill JFK. We can go through the fact that he's made some statements that some have identified correctly as religiously intolerant. We can get into the fact that he's wildly unpopular in my state, in part because my state consists of people who are members of a religious minority church — a people who were ordered exterminated by the governor of Missouri in 1838 — and, statements like that make them nervous."


Read full article from GOP Senator Goes on Epic Anti-Trump Rant When Asked Why He Hasn't Endorsed Yet | Mediaite


Inter-thread Communication in Java - GeeksforGeeks



Inter-thread Communication in Java - GeeksforGeeks

What is Polling and what are problems with it?
The process of testing a condition repeatedly till it becomes true is known as polling.

Polling is usually implemented with the help of loops to check whether a particular condition is true or not. If it is true, certain action is taken. This waste many CPU cycles and makes the implementation inefficient.
For example, in a classic queuing problem where one thread is producing data and other is consuming it.

How Java multi threading tackles this problem?
To avoid polling, Java uses three methods, namely, wait(), notify() and notifyAll().
All these methods belong to object class as final so that all classes have them. They must be used within a synchronized block only.

  • wait()-It tells the calling thread to give up the lock and go to sleep until some other thread enters the same monitor and calls notify().
  • notify()-It wakes up one single thread that called wait() on the same object. It should be noted that calling notify() does not actually give up a lock on a resource.
  • notifyAll()-It wakes up all the threads that called wait() on the same object.


Read full article from Inter-thread Communication in Java - GeeksforGeeks


Find subarray with given sum | Set 1 (Nonnegative Numbers) - GeeksforGeeks



Find subarray with given sum | Set 1 (Nonnegative Numbers) - GeeksforGeeks

Given an unsorted array of nonnegative integers, find a continous subarray which adds to a given number.

Examples:

Input: arr[] = {1, 4, 20, 3, 10, 5}, sum = 33  Ouptut: Sum found between indexes 2 and 4    Input: arr[] = {1, 4, 0, 0, 3, 10, 5}, sum = 7  Ouptut: Sum found between indexes 1 and 4    Input: arr[] = {1, 4}, sum = 0  Output: No subarray found  

There may be more than one subarrays with sum as the given sum. The following solutions print first such subarray.

Source: Google Interview Question


Read full article from Find subarray with given sum | Set 1 (Nonnegative Numbers) - GeeksforGeeks


Find subarray with given sum | Set 2 (Handles Negative Numbers) - GeeksforGeeks



Find subarray with given sum | Set 2 (Handles Negative Numbers) - GeeksforGeeks

Given an unsorted array of integers, find a subarray which adds to a given number. If there are more than one subarrays with sum as the given number, print any of them.

Examples:

Input: arr[] = {1, 4, 20, 3, 10, 5}, sum = 33  Ouptut: Sum found between indexes 2 and 4    Input: arr[] = {10, 2, -2, -20, 10}, sum = -10  Ouptut: Sum found between indexes 0 to 3    Input: arr[] = {-10, 0, 2, -2, -20, 10}, sum = 20  Ouptut: No subarray with given sum exists  

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

We have discussed a solution that do not handles negative integers here. In this post, negative integers are also handled.

A simple solution is to consider all subarrays one by one and check if sum of every subarray is equal to given sum or not. The complexity of this solution would be O(n^2).

An efficient way is to use a map. The idea is to maintain sum of elements encountered so far in a variable (say curr_sum). Let the given number is sum. Now for each element, we check if curr_sum – sum exists in the map or not. If we found it in the map that means, we have a subarray present with given sum, else we insert curr_sum into the map and proceed to next element. If all elements of the array are processed and we didn't find any subarray with given sum, then subarray doesn't exists.


Read full article from Find subarray with given sum | Set 2 (Handles Negative Numbers) - GeeksforGeeks


Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages) - GeeksforGeeks



Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages) - GeeksforGeeks

Ever wondered how sort() function we use in C++/Java or sorted() in Python work internally?

Here is a list of all the inbuilt sorting algorithms of different programming languages and the algorithm they use internally.

  1. C's qsort() – Quicksort

    • Best Case Time Complexity- O(NlogN)
    • Average Case Time Complexity- O(NlogN)
    • Worse Case Time Complexity- O(N2)
    • Auxiliary Space- O(log N)
    • Stable- Depends on the implementation of the comparator function
    • Adaptive- No
  2. C++'s sort() – Introsort (Hybrid of Quicksort, Heap Sort and Insertion Sort)
    • Best Case Time Complexity- O(NlogN)
    • Average Case Time Complexity- O(NlogN)
    • Worse Case Time Complexity- O(NlogN)
    • Auxiliary Space- O(logN)
    • Stable- No
    • Adaptive- No
  3. C++'s stable_sort() – Mergesort
    • Best Case Time Complexity- O(NlogN)
    • Average Case Time Complexity- O(NlogN)
    • Worse Case Time Complexity- O(NlogN)
    • Auxiliary Space- O(N)
    • Stable- Yes
    • Adaptive- Yes
  4. Java 6's Arrays.sort() – Quicksort
    • Best Case Time Complexity- O(NlogN)
    • Average Case Time Complexity- O(NlogN)
    • Worse Case Time Complexity- O(N2)
    • Auxiliary Space- O(logN)
    • Stable- Depends
    • Adaptive- No
  5. Java 7's Arrays.sort() – Timsort (Hybrid of Mergesort and Insertion Sort)
    • Best Case Time Complexity- O(N)
    • Average Case Time Complexity- O(NlogN)
    • Worse Case Time Complexity- O(NlogN)
    • Auxiliary Space- O(N)
    • Stable- Yes
    • Adaptive- Yes
  6. Java's Collections.sort() – Mergesort
    • Best Case Time Complexity- O(NlogN)
    • Average Case Time Complexity- O(NlogN)
    • Worse Case Time Complexity- O(NlogN)
    • Auxiliary Space- O(N)
    • Stable- Yes
    • Adaptive- Yes
  7. Python's sorted() – Timsort (Hybrid of Mergesort and Insertion Sort)
    • Best Case Time Complexity- O(N)
    • Average Case Time Complexity- O(NlogN)
    • Worse Case Time Complexity- O(NlogN)
    • Auxiliary Space- O(N)
    • Stable- Yes
    • Adaptive- Yes
  8. Python's sort() – Timsort (Hybrid of Mergesort and Insertion Sort)
    • Best Case Time Complexity- O(N)
    • Average Case Time Complexity- O(NlogN)
    • Worse Case Time Complexity- O(NlogN)
    • Auxiliary Space- O(N)
    • Stable- Yes
    • Adaptive- Yes

Read full article from Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages) - GeeksforGeeks


Leetcode 368. Largest Divisible Subset - Deribs4 - 博客园



Leetcode 368. Largest Divisible Subset - Deribs4 - 博客园

368. Largest Divisible Subset

Total Accepted: 864 Total Submissions: 2728 Difficulty: Medium

 

Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.

If there are multiple solutions, return any subset is fine.

Example 1:

nums: [1,2,3]    Result: [1,2] (of course, [1,3] will also be ok)

 

Example 2:

nums: [1,2,4,8]    Result: [1,2,4,8]

 

思路:

定义T[n]为最大值为nums[n]的满足题意的子集元素个数。
显然如果存在i(i<n),有nums[n]%nums[i],T[n]=max{T[i]+1};否则,T[n]=1。

 


Read full article from Leetcode 368. Largest Divisible Subset - Deribs4 - 博客园


You're right, George Will: GOP isn't your party (opinion) - CNN.com



You're right, George Will: GOP isn't your party (opinion) - CNN.com

You're right, George Will: GOP isn't your party By Dean Obeidallah JUST WATCHED Story highlights Obeidallah: GOP base largely aligned with Trump, out of step with party elders Will is right that GOP is 'not my party,' Obeidallah says. So what comes next? Dean Obeidallah, a former attorney, is the host of SiriusXM's weekly program "The Dean Obeidallah Show," a columnist for The Daily Beast and editor of the politics blog The Dean's Report . Follow him on Twitter: @TheDeansreport . The opinions expressed in this commentary are his. (CNN) Donald Trump loves to brag that "millions and millions of people have come to the Republican Party" because of his campaign. Like many of Trump's claims, that one appears be questionable, according to Politico's analysis of primary voting data. But one thing is demonstrably true: Trump is driving Republicans out of the GOP. On Friday,

Read full article from You're right, George Will: GOP isn't your party (opinion) - CNN.com


Open Sourcing Twitter Heron | Twitter Blogs



Open Sourcing Twitter Heron | Twitter Blogs

Last year we announced the introduction of our new distributed stream computation system, Heron. Today we are excited to announce that we are open sourcing Heron under the permissive Apache v2.0 license. Heron is a proven, production-ready, real-time stream processing engine, which has been powering all of Twitter's real-time analytics for over two years. Prior to Heron, we used Apache Storm, which we open sourced in 2011. Heron features a wide array of architectural improvements and is backward compatible with the Storm ecosystem for seamless adoption.


Read full article from Open Sourcing Twitter Heron | Twitter Blogs


(10) What do you think of CodePair by HackerRank? - Quora



(10) What do you think of CodePair by HackerRank? - Quora

In short though, it does a bunch of things that I don't care about and doesn't do the things I want. (This is not, however, to say that it doesn't do what other people want. It just doesn't do what I want.)

Things I don't care about that it has
I don't really care about syntax highlighting and code execution. They're sort of a distraction to me.

Look, I don't care if someone has their syntax quite right. Does a linked list in Java use add, append, enqueue, insert, or push? I have no idea, and I don't really care if you do either.

It's also not really realistic to write 100% runnable code in many situations. What, are you going to call your ready-made Trie library with the English language built in?

Offering syntax highlighting and code execution makes candidates feel like syntactically correct code matters. It doesn't.

Thus, offering these features (especially code execution) is a very slight negative to me. I would probably turn them off if it offered this ability.

Additionally, if this is a phone interview being given to screen for an onsite interview, I'd like the phone interview to be as much like an in-person interview as possible. An in-person interview doesn't have syntax highlighting or code execution, so why should a phone interview?

Things I care about that it doesn't have:
You know what I get frustrated by in a phone interview? The lack of a whiteboard.

I want to be able to go up to the whiteboard and just quickly draw a diagram. Drawing by hand is easy! I can draw a table, and then draw an arrow coming off it, and then some text underneath that, and then a binary tree branching off of it. Wheeeeee!


Read full article from (10) What do you think of CodePair by HackerRank? - Quora


Clinton, Obama hail Supreme Court abortion decision - POLITICO



Clinton, Obama hail Supreme Court abortion decision - POLITICO

The Supreme Court's 5-3 decision striking down two provisions of a sweeping anti-abortion law in Texas "is a victory for women in Texas and across America," but the fight over women's rights isn't over, Hillary Clinton said Monday, while Republicans and conservatives condemned the ruling.

"SCOTUS's decision is a victory for women in Texas and across America. Safe abortion should be a right—not just on paper, but in reality," the presumptive Democratic presidential nominee tweeted.

Story Continued Below


Read full article from Clinton, Obama hail Supreme Court abortion decision - POLITICO


leetcode Create Maximum Number - 细语呢喃



leetcode Create Maximum Number - 细语呢喃

Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k digits. You should try to optimize your time and space complexity.

Example 1:

nums1 = [3, 4, 6, 5]
nums2 = [9, 1, 2, 5, 8, 3]
k = 5
return [9, 8, 6, 5, 3]

Example 2:

nums1 = [6, 7]
nums2 = [6, 0, 4]
k = 5
return [6, 7, 6, 0, 4]

Example 3:

nums1 = [3, 9]
nums2 = [8, 9]
k = 3
return [9, 8, 9]

题目地址:leetcode Create Maximum Number

题意

给定两个长度为m和n的数组,他们由0~9的数组组成,现在,让你通过这两个数组中的数字组建一个长度为k 的数组(k<=m+n) ,原来数组的相对顺序要保留。

思路

递归写法TLE了。

问了一下CJL的思路~其实都差不多。我是直接原串找当前符合条件的最大的值,然后递归,他是枚举长度,然后找符合长度的。。。

第7个AC~哈哈~

我A这题的时候。。。这题一共 7个AC,410+次提交。。。通过率1%…  难度medium,现在改成hard了。。。

枚举第一个数组A的个数i,那么数组B的个数就确定了 k -i。

然后枚举出A和B长度分别为i和k-i的最大子数组,(可以用栈,类似leetcode Remove Duplicate Letters

最后组合看看哪个大。

组合的过程类似合并排序,看看哪个数组大,就选哪个。

枚举数组长度复杂度O(k),找出最大子数组O(n),合并的话O(k^2)

而k最坏是m+n,所以总的复杂度就是O((m+n)^3)


Read full article from leetcode Create Maximum Number - 细语呢喃


[leetcode] 321. Create Maximum Number 解题报告 - 小榕流光的专栏 - 博客频道 - CSDN.NET



[leetcode] 321. Create Maximum Number 解题报告 - 小榕流光的专栏 - 博客频道 - CSDN.NET

Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k digits. You should try to optimize your time and space complexity.

Example 1:

nums1 = [3, 4, 6, 5]
nums2 = [9, 1, 2, 5, 8, 3]
k = 5
return [9, 8, 6, 5, 3]

Example 2:

nums1 = [6, 7]
nums2 = [6, 0, 4]
k = 5
return [6, 7, 6, 0, 4]

Example 3:

nums1 = [3, 9]
nums2 = [8, 9]
k = 3
return [9, 8, 9]



思路: 也是麻烦的一题. 思路是从nums1中取i个最大值,从nums2中取k-i个最大值, 然后枚举各个i,然后合并取比较大的. 但是在具体的实现中其实还是比较麻烦的.

首先从一个数组取i个大的值时, 我们要尽量保留其降序的序列, 除非剩余的元素个数不足我们要取的个数

然后是合并的时候, 如果两个元素的当前元素相等, 那么我们还要考虑其后序元素的大小.

代码如下:


Read full article from [leetcode] 321. Create Maximum Number 解题报告 - 小榕流光的专栏 - 博客频道 - CSDN.NET


Julia's coding blog - Practice makes perfect: AorB - HackerRank workout example



Julia's coding blog - Practice makes perfect: AorB - HackerRank workout example

 A small problem related to AorB problem, and get some workout on bit manipulation. Still work on desigining a well-defined problem - something small enough, meaningful enough.

Read full article from Julia's coding blog - Practice makes perfect: AorB - HackerRank workout example


Unique Binary Search Trees II leetcode java - 爱做饭的小莹子 - 博客园



Unique Binary Search Trees II leetcode java - 爱做饭的小莹子 - 博客园

Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.

For example,
Given n = 3, your program should return all 5 unique BST's shown below.

   1         3     3      2      1     \       /     /      / \      \      3     2     1      1   3      2     /     /       \                 \    2     1         2                 3 

题解
这道题比1难的就是不是返回个数,而是返回所有结果。
引用code ganker(http://codeganker.blogspot.com/2014/04/unique-binary-search-trees-ii-leetcode.html)的讲解:
"这道题是求解所有可行的二叉查找树,从Unique Binary Search Trees中我们已经知道,可行的二叉查找树的数量是相应的卡特兰数,不是一个多项式时间的数量级,所以我们要求解所有的树,自然是不能多项式时间内完成的了。算法上还是用求解NP问题的方法来求解,也就是N-Queens中 介绍的在循环中调用递归函数求解子问题。思路是每次一次选取一个结点为根,然后递归求解左右子树的所有结果,最后根据左右子树的返回的所有子树,依次选取 然后接上(每个左边的子树跟所有右边的子树匹配,而每个右边的子树也要跟所有的左边子树匹配,总共有左右子树数量的乘积种情况),构造好之后作为当前树的 结果返回。 "
这道题的解题依据依然是:
当数组为 1,2,3,4,.. i,.. n时,基于以下原则的BST建树具有唯一性: 以i为根节点的树,其左子树由[1, i-1]构成, 其右子树由[i+1, n]构成。

Read full article from Unique Binary Search Trees II leetcode java - 爱做饭的小莹子 - 博客园


Solution - LeetCode 336. Palindrome Pairs | Hunter's Code



Solution - LeetCode 336. Palindrome Pairs | Hunter's Code

Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.

Example 1:
Given words = ["bat", "tab", "cat"]
Return [[0, 1], [1, 0]]
The palindromes are ["battab", "tabbat"]
Example 2:
Given words =["abcd", "dcba", "lls", "s", "sssll"]Return[[0, 1], [1, 0], [3, 2], [2, 4]]The palindromes are["dcbaabcd", "abcddcba", "slls", "llssssll"]`

The key point of this problem is to find whether each word in the given array has a substring which is a palindrome. If so, check other words one by one to see if the concatenation can be a palindrome; or find out a revserse word of the current one.

Therefore, we need to implement Manacher's algorithm of Longest Palindromic Substring

Also, we can use Trie structure, but…, anyway it's a good chance to learn this advanced structure right now.

However, I only come up with a brute force solution, which checks every pairs of words to see if the concatenation is a palindrome.


Read full article from Solution - LeetCode 336. Palindrome Pairs | Hunter's Code


Buttercola: Leetcode: 340. Longest Substring with At Most K Distinct Characters



Buttercola: Leetcode: 340. Longest Substring with At Most K Distinct Characters

Given a string, find the length of the longest substring T that contains at most k distinct characters.
For example, Given s = "eceba" and k = 2,
T is "ece" which its length is 3.
Understand the problem:
The problem is very similar to the Leetcode question 3 (Longest Substring Without Repeating Characters). 

The key idea of the solution is to use two pointers to maintain a "sliding window". We also use a HashMap to store all the characters in the window. Each time we move forward the "start" pointer and increase the size of the sliding window until the size of the window is greater than K. Then we can easily calculate the size of the window which contains at most K distinct characters. The next step is to shrink the window by moving forward the "end" pointer. In order to get the maximum window size, we must move the minimum steps of the end pointer. So each step we move the end pointer, we need to update the map and remove the character out of the sliding window. The stop condition is that when the window size is again equal to the K, which means the window contains K distinct characters. That's the minimum steps we need to move forward the end pointer. 

The only trick here is we need to check at the last that if the start pointer is out of boundary, we still need to check if the largest window size. That's a common trick for major string w/ two pointer problems.

Read full article from Buttercola: Leetcode: 340. Longest Substring with At Most K Distinct Characters


leetcode: Two Sum - 点缀星辰 - ITeye技术网站



leetcode: Two Sum - 点缀星辰 - ITeye技术网站

    Given an array of integers, find two numbers such that they add up to a specific target number.

The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.

You may assume that each input would have exactly one solution.

Input: numbers={2, 7, 11, 15}, target=9
Output: index1=1, index2=2

 

原问题链接:https://oj.leetcode.com/problems/two-sum/

 

问题分析

  这个问题相对来说比较简单,在给定一组数字的时候,我们需要去找两个数字之和为给定数字的一个组合。所以从最开始来说,一个最简单直接的方法就是二重循环遍历数组,找到匹配的就返回。这种方法的实现如下:

Java代码  收藏代码

Read full article from leetcode: Two Sum - 点缀星辰 - ITeye技术网站


Julia's coding blog - Practice makes perfect: Leetcode 318: Maximum Product of Word Length



Julia's coding blog - Practice makes perfect: Leetcode 318: Maximum Product of Word Length

1. Always work on coding, using Visual Studio. Try to improve coding. 

Leetcode 318: Maximum Product of Word Length 
Given a string array words, find the maximum value of length(word[i]) * length(word[j])where the two words do not share common letters. You may assume that each word will contain only lower case letters. If no such two words exist, return 0.
https://www.hrwhisper.me/leetcode-maximum-product-of-word-lengths/ 

Solution 1:
直接看看每个字符串都包括了哪个字符,然后一一枚举是否有交集:
  • 有交集,则乘积为0
  • 无交集,乘积为 words[i].length() * words[j].length()
Julia's practice: 

Solution 2:
其实因为全部都是小写的字母,用int 就可以存储每一位的信息。这就是位运算
  • elements[i] |= 1 << (words[i][j] – 'a');   //把words[i][j] 在26字母中的出现的次序变为1
  •  elements[i] & elements[j]    // 判断是否有交集只需要两个数 按位 与 (AND)运算即可
read the blog to understand bit operation, take some time to refresh the memory:
http://www.cnblogs.com/onlyac/p/5155881.html


在一个字符串组成的数组words中,找出max{Length(words[i]) * Length(words[j]) },其中words[i]和words[j]中没有相同的字母,在这里字符串由小写字母a-z组成的。
对于这道题目我们统计下words[i]的小写字母a-z是否存在,然后枚举words[i]和words[j],找出max{Length(words[i]) * Length(words[j]) }。

小写字母a-z是26位,一般统计是否存在我们要申请一个bool flg[26]这样的数组,但是我们在这里用int代替,int是32位可以替代flg数组,用 与(&),或(1),以及向左移位(<<)就能完成。如"abcd" 的int值为 0000 0000 0000 0000 0000 0000 0000 1111,"wxyz" 的int值为 1111 0000 0000 0000 0000 0000 0000 0000,这样两个进行与(&)得到0, 如果有相同的字母则不是0。

Read full article from Julia's coding blog - Practice makes perfect: Leetcode 318: Maximum Product of Word Length


318. Maximum Product of Word Lengths - YRB - 博客园



318. Maximum Product of Word Lengths - YRB - 博客园

Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case letters. If no such two words exist, return 0.

Example 1:

Given ["abcw", "baz", "foo", "bar", "xtfn", "abcdef"]
Return 16
The two words can be "abcw", "xtfn".

Example 2:

Given ["a", "ab", "abc", "d", "cd", "bcd", "abcd"]
Return 4
The two words can be "ab", "cd".

Example 3:

Given ["a", "aa", "aaa", "aaaa"]
Return 0
No such pair of words.

链接: https://leetcode.com/problems/maximum-product-of-word-lengths/

题解:

给定一个String array,求出不含相同字符的两个单词长度乘积的最大值。

我们可以把这道题目分为几个步骤。 

  1. 双重循环遍历Words
  2. 先把words[i]和words[j]放入一个<String, Set<Character>>的HashMap里
  3. 比较两者是否有重复, 假如没有重复,我们可以尝试更新max, 否则continue
  4. 最后返回max

这里题目给出单词只包含小写字母,所以我们还可以进一步优化空间复杂度。 另外,预先对数组按长度进行排序的话应该可以剪枝掉不少计算。 留给二刷了。

Java:


Read full article from 318. Maximum Product of Word Lengths - YRB - 博客园


Find Peak Element | LeetCode题解



Find Peak Element | LeetCode题解

A peak element is an element that is greater than its neighbors.

Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.

The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.

You may imagine that num[-1] = num[n] = -∞.

For example, in array [1, 2, 3, 1], 3 is a peak element and your function should return the index number 2.

这题要求我们在一个无序的数组里面找到一个peak元素,所谓peak,就是值比两边邻居大就行了。

对于这题,最简单地解法就是遍历数组,只要找到第一个元素,大于两边就可以了,复杂度为O(N)。但这题还可以通过二分来做。

首先我们找到中间节点mid,如果大于两边返回当前index就可以了,如果左边的节点比mid大,那么我们可以继续在左半区间查找,这里面一定存在一个peak,为什么这么说呢?假设此时的区间范围为[0, mid - 1], 因为num[mid - 1]一定大于num[mid]了,如果num[mid - 2] <= num[mid - 1],那么num[mid - 1]就是一个peak。如果num[mid - 2] > num[mid - 1],那么我们就继续在[0, mid - 2]区间查找,因为num[-1]为负无穷,所以最终我们绝对能在左半区间找到一个peak。同理右半区间一样。

代码如下:


Read full article from Find Peak Element | LeetCode题解


Snakes and Ladders Game Code



Snakes and Ladders Game Code

Now, Graph Theory has many applications and I love working with things that have real-world applications, well, off course the other data structures too have their uses, but the speciality of Graph Theory is its applications have the closest association with our day-to-day activities. And to show you this and to set an example on how the BFS is actually put into action, I am taking up the example of the very popular game, Snakes and Ladders.

This game needs no introduction. We all must have played it in our childhood. I will explain you, how by using Graphs and BFS we can find the Shortest Path to win the game, and, we will state that path and the number of moves of dice it takes too. Have a good look at the Snakes and Ladder board below, we will be using it as an example throughout this post.


Read full article from Snakes and Ladders Game Code


翻译:《蛇棋》游戏与算法 - 技术总结 - SegmentFault



翻译:《蛇棋》游戏与算法 - 技术总结 - SegmentFault

大家好,《蛇棋》游戏旨在寻找最短路径,本文讲解如何使用广度优先遍历算法BFS,不了解该算法的同学,请参考这篇文章)来解决该问题。

笔者喜欢实用的技术,而图论就是其一。诚然,其他数据结构也应用广泛,但由于图论的特性,使其与我们的生活联系最为紧密。接下来,笔者就用经典游戏《蛇棋》举例,说明如何使用BFS来解决实际生活中的问题。

想必大家小时候一定都玩过《蛇棋》,规则就不多说了。而这里要说的,则是如何通过图论和BFS,找到最短的路径(掷骰子的次数,以及每次掷的点数),抵达终点赢取胜利。下图为蛇棋棋盘,本文将以它来举例说明。


Read full article from 翻译:《蛇棋》游戏与算法 - 技术总结 - SegmentFault


“HTTPS”安全在哪里? - 技术分享 - Bugly - Powered by Bugly!



"HTTPS"安全在哪里? - 技术分享 - Bugly - Powered by Bugly!

最近基于兴趣学学习了下 HTTPS 相关的知识,在此记录下学习心得。 在上网获取信息的过程中,我们接触最多的信息加密传输方式也莫过于 HTTPS 了。每当访问一个站点,浏览器的地址栏中出现绿色图标时,意味着该站点支持 HTTPS 信息传输方式。我们知道 HTTPS 是我们常见的 HTTP 协议与某个加密协议的混合体,也就是 HTTP+S。这个 S 可以是 TLS(安全传输层协议)、也可以是 SSL(安全套接层),不过我更认可另一个抽象概括的说法,HTTP+Security。不过要谈论 HTTPS 为何安全,还得从 HTTP 为何不安全说起。 假设你现在正坐在教室里上课,现在你非常想和走道旁的迷人的 TA 说一些话,一般这个时候你会用"传纸条"的方式来交流。而这个方式和 TCP/IP 协议基本的工作模式十分相像: 通过小动作引起对方注意; 如果你要传递纸条的 TA 距离你很远怎么办?HTTP 协议就是指你在纸条上写明你要传给的 TA 是谁,或者 TA 的座位在哪,接着只需要途径的同学拿到纸条后根据纸条上的指示依次将纸条传过去就 OK 了。 这个时候问题来了:途径的同学完全可以观看并知道你在纸条上写了什么。 加密 对称加密算法既指加密和解密需要使用的密钥 key 是一样的。 我们先假设在没有密钥 key 的情况下,密文是无法被破解的,然后再回到这个教室。你将用 AES 加密后的内容噌噌噌地写在了纸条上,正要传出去的时候你突然想到,TA 没有 key 怎么解密内容呀,或者说,应该怎么把 key 给TA? 如果把 key 也写在纸条上,那么中间人照样可以破解窃听纸条内容。也许在现实环境中你有其他办法可以把 key 通过某种安全的渠道送到 TA 的手里,但是互联网上的实现难度就比较大了,毕竟不管怎样,数据都要经过那些路由。 于是聪明的人类发明了另一种加密算法——非对称加密算法。这种加密算法会生成两个密钥(key1 和 key2)。凡是 key1 加密的数据,key1 自身不能解密,需要 key2 才能解密;凡事 key2 加密的数据,key2 自身不能解密,只有 key1 才能解密。 目前这种算法有很多中,最常用的是 RSA。其基于的数学原理是: 现在就把这种非对称加密的方法应用在我们教室传纸条的场景里。 你在写纸条内容之前先用 RSA 技术生成了一对密钥 k1 和 k2。

Read full article from "HTTPS"安全在哪里? - 技术分享 - Bugly - Powered by Bugly!


Java O(1) solution, easy to understand - Leetcode Discuss



Java O(1) solution, easy to understand - Leetcode Discuss

Initially, I had not read the Hint in the question and came up with an O(n) solution. After reading the extremely helpful hint; a much easier approach became apparent. The key observation is that in order to win Tic-Tac-Toe you must have the entire row or column. Thus, we don't need to keep track of an entire n^2 board. We only need to keep a count for each row and column. If at any time a row or column matches the size of the board then that player has won.

To keep track of which player, I add one for Player1 and -1 for Player2. There are two additional variables to keep track of the count of the diagonals. Each time a player places a piece we just need to check the count of that row, column, diagonal and anti-diagonal.

Also see a very similar answer that I believe had beaten me to the punch. We came up with our solutions independently but they are very similar in principle. Aeonaxx's soln


Read full article from Java O(1) solution, easy to understand - Leetcode Discuss


George Will says he's leaving GOP over Trump - CNNPolitics.com



George Will says he's leaving GOP over Trump - CNNPolitics.com

Washington (CNN)Conservative commentator and columnist George Will says he is leaving the Republican Party because of Donald Trump -- and he's advocating that others do the same.


Read full article from George Will says he's leaving GOP over Trump - CNNPolitics.com


Group Tries Shoplifting, Then Beats Man in SF Mission » MissionLocal



Group Tries Shoplifting, Then Beats Man in SF Mission » MissionLocal

By Joe Rivano Barros Posted June 24, 2016 11:17 am A man was taken to the hospital late Thursday after being pummeled by three men on the edge of the Mission District. At 11:47 p.m., a 20-year-old man was in a store on 16th Street between Bryant and Potrero when a group of two men and one woman in their 20s attempted to shoplift, getting into an argument with the man. One of the men in the group punched the victim multiple times while the woman put him in a headlock, before the three fled on foot without having stolen anything. The man was transported to the hospital but was in stable condition. The police did not say whether the victim was an employee of the store or which store the assault occurred in, and they have not made an arrest. And at 2:40 p.m. on Thursday, a 49-year-old man was standing on the corner of 24th and Mission streets waiting for the bus when a woman and a man in their 20s exited a bus and approached the man.

Read full article from Group Tries Shoplifting, Then Beats Man in SF Mission » MissionLocal


The Old Reader



The Old Reader

编者按:淘宝自从2010开始规模使用MySQL,替换了之前商品、交易、用户等原基于IOE方案的核心数据库,目前已部署数千台规模。同时和Oracle, Percona, Mariadb等上游厂商有良好合作,共向上游提交20多个Patch。目前淘宝核心系统研发部数据库组,根据淘宝的业务需求,改进数据库和提升性能,提供高性能、可扩展的、稳定可靠的数据库(存储)解决方案。 目前有以下几个方向:单机,提升单机数据库的性能,增加我们所需特性;集群,提供性能扩展,可靠性,可能涉及分布式事务处理;IO存储体系,跟踪IO设备变化潮流, 研究软硬件结合,输出高性能存储解决方案。本文是来自淘宝内部数据库内容分享。

MySQL · 性能优化· Group Commit优化

背景

关于Group Commit网上的资料其实已经足够多了,我这里只简单的介绍一下。

众所周知,在MySQL5.6之前的版本,由于引入了Binlog/InnoDB的XA,Binlog的写入和InnoDB commit完全串行化执行,大概的执行序列如下:

InnoDB prepare (持有prepare_commit_mutex);
write/sync Binlog;
InnoDB commit (写入COMMIT标记后释放prepare_commit_mutex)。

当sync_binlog=1时,很明显上述的第二步会成为瓶颈,而且还是持有全局大锁,这也是为什么性能会急剧下降。

很快Mariadb就提出了一个Binlog Group Commit方案,即在准备写入Binlog时,维持一个队列,最早进入队列的是leader,后来的是follower,leader为搜集到的队列中的线程依次写Binlog文件, 并commit事务。Percona 的Group Commit实现也是Port自Mariadb。不过仍在使用Percona Server5.5的朋友需要注意,该Group Commit实现可能破坏掉Semisync的行为,感兴趣的点击 bug#1254571


Read full article from The Old Reader


Design hash table | LeetCode Discuss



Design hash table | LeetCode Discuss

Design a data structure Map<Integer, Integer> supporting the following operations and requirements:

  1. add: O(1)
  2. delete: O(1)
  3. lookup: O(1)
  4. clear:O(1)
  5. iterate: O(number of elements)

Read full article from Design hash table | LeetCode Discuss


Nested List Weight Sum II | LeetCode Discuss



Nested List Weight Sum II | LeetCode Discuss

Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Different from the previous question where weight is increasing from root to leaf. Now the weight is defined from bottom up. I.e. the leaf level integers have weight 1, and the root level integers have the largest weight.

Each element is either an integer, or a list -- whose elements may also be integers or other lists.

Example 1:
Given the list [[1,1],2,[1,1]], return 8. (four 1's at depth 1, one 2 at depth 2)

Example 2:
Given the list [1,[4,[6]]], return 17. (one 1 at depth 3, one 4 at depth 2, and one 6 at depth 1; 13 + 42 + 6*1 = 17)


Read full article from Nested List Weight Sum II | LeetCode Discuss


Sum of Two Integers | LeetCode Discuss



Sum of Two Integers | LeetCode Discuss

Calculate the sum of two integers, but you are not allowed to use the operator + and -.

Example:

Given [1, 2], return 3.  

Read full article from Sum of Two Integers | LeetCode Discuss


Glow Cache 构架



Glow Cache 构架

什么是Cache Wiki上说:a cache is a component that stores data so future requests for that data can be served faster 在绝大多数服务器框架中,就是用内存代替数据库,以达到提高速度的目的。 Cache hit rate 你不可能无限制地把所有数据都写入cache中,cache system总会把一些数据丢弃。当一个"读"操作访问了不在cache中的数据,会产生一次backend storage读,以及一次cache"写"(写回cache),我们称之为cache miss。显然,一个cache miss会比直接访问backend storage有更大的开销。因此一个成熟的cache系统,应该极大地降低cache miss,保持cache hit在90%,甚至更高。 Glow Cache 概括 不管是write-through还是write-back,任何一次"写"操作,都会更新cache。而cache的目的,是提高"读"操作的速度。细心的读者或许会发现,这其中有一些逻辑上的问题:如果"写"完的数据,不再被"读",不是白写了? 的确。如果"写"操作和"读"操作相对平衡,那这样的设计将会有比较好的效果。因为cache system会定期把数据丢弃。如果"写"进cache的数据,有90%在被cache丢弃前就被"读"过,那么hit rate就有90%。但实际生产环境中,我们发现,"写"操作和"读"操作并不平衡: 在用户记录健康信息的时候,"读"操作远远低于"写"操作,而"写"进cache的数据,一部分会被马上"读"到,另一部分不会被马上"读"到。 而在用户浏览论坛的时候,"读"操作则远远高于"写"操作,并且"读"操作请求的数据,大部分都不是刚被"写"过的。 为了达到90% cache hit rate,提高cache的容量,是一个简单粗暴的方式。这样,"写"进cache的数据,会存留更多的时间,随时准备被"读"。但随着数据量越来越大,经济成本会越来越高,即便一个创业团队能负担的起,也非常不划算——性价比太低。 作为一个服务器构架师,创业公司的程序猿,应该采用最合适的技术框架,即解决问题又节约成本。于是,Glow的cache,是一种结合了write-through和write-

Read full article from Glow Cache 构架


Print shortest path to print a string on screen - GeeksforGeeks



Print shortest path to print a string on screen - GeeksforGeeks

Given a screen containing alphabets from A-Z, we can go from one character to another characters using a remote. The remote contains left, right, top and bottom keys.


Read full article from Print shortest path to print a string on screen - GeeksforGeeks


Lower case to upper case - An interesting fact - GeeksforGeeks



Lower case to upper case - An interesting fact - GeeksforGeeks

Explanation: The ASCII table is constructed in such way that the binary representation of lowercase letters is almost identical of binary representation of uppercase letters. The only difference is the sixth bit, setted only for lowercase letters. What that elegant function does is unset the bit of index 5 of in[i], consequently, making that character lowercase.

Disadvantages:
That strategy works only for alphabetical characters. If the input contains numbers or punctuations, we'll have to use the naive way.

Example:
Character 'A' is integer 65 = (0100 0001)2, while character 'a' is integer = 97 = (0110 0001)2. (Note that 97 – 65 = 32. Can you guess why?)

Exercises:

  1. Write a function to make all letters of a string lowercase. Example: GeeksForGeeks turns geeksforgeeks.
  2. Write a function that change the case of a string. Example: GeeksForGeeks turns gEEKSfORgEEKS.


Read full article from Lower case to upper case - An interesting fact - GeeksforGeeks


This List Shows When Nexus Devices Will Stop Receiving Android Updates



This List Shows When Nexus Devices Will Stop Receiving Android Updates

Reliable Android updates are a key selling point of Google's Nexus line of phones. Even Nexuses have an expiration date, though. Now, Google has a published list of when you can stop expecting updates for your Nexus phone or tablet. The list can be found here , on one of Google's support pages under "How long your Nexus will get updates." Currently the Nexus 5X and Nexus 6P are the safest, with promised Android version updates lasting at least through September 2017. Most other Nexus devices are either past their expiration date already or, in the case of the Nexus 6 and 9, will expire in October of 2016. Google specifically notes that past these dates there's no guarantee of an update. It's entirely possible that Google may decide to give a little more life to certain devices at their discretion, but you probably shouldn't count on it. Also, these dates only apply to Android version updates.

Read full article from This List Shows When Nexus Devices Will Stop Receiving Android Updates


What Trump’s money troubles really tell us



What Trump's money troubles really tell us

View photos The candidate speaking at Trump SoHo Hotel in New York City on June 22. (Photo: Drew Angerer/Getty Images) More More incredible news for the Donald Trump juggernaut! After a 10-day stretch in which Trump found himself rebuked by Republican leaders, plummeting in polls and firing his much-maligned campaign manager , news broke that, according to public filings, his campaign now had about $1.3 million in the bank. This is awesome if you're running for a House seat in, say, Maine. It's slightly less awesome if you're running for president. How much less awesome? About 40 times less than what Hillary Clinton has at her disposal — not counting outside groups that have been revving up on her behalf for at least a year. So, yeah, a lot less awesome. This really is something, considering that all through the primaries Trump bragged about how he was so rich you wouldn't believe and how he was the only guy on stage who didn't need to ask for money.

Read full article from What Trump's money troubles really tell us


My Solution to A Distance Maximizing Problem - kkmm - 博客园



My Solution to A Distance Maximizing Problem - kkmm - 博客园

由2个元素开始作为初始条件,一个一个元素的添加进现有数组,保存2个变量,1个是currMin,就是当前处理的子数组的最小元素,一个是maxDiff,就是当前处理的子数组中最大的数对之差。如果当前添加的元素比min小,更新min,如果当前添加的元素减去min比maxDiff大,那么更新maxDiff。


Read full article from My Solution to A Distance Maximizing Problem - kkmm - 博客园


(10) I have an array of n integers. How many subarrays are contained in my array? - Quora



(10) I have an array of n integers. How many subarrays are contained in my array? - Quora

For an array with distinct elements, it would be same as the number of ways of choosing two indices i,j such that the following conditions are met
1. i <= j,
2. i,j >= 0 (assumption indices run from 0 to n-1)
3. i,j < n

When i = 0, j can run from 0 to n-1 i.e. n choices
When i =1, j can run from 1 to n-1
.
.
When i =n-1 j can be only n-1

Summing the terms up gives us n + (n-1) + (n-2) + ... + 1

=n(n+1)/2

However for repeated elements the answer will vary with the contents of the array.

I will try to find some generalized equation for the same, but I doubt there is one.

Read full article from (10) I have an array of n integers. How many subarrays are contained in my array? - Quora


What Trump’s money troubles really tell us



What Trump's money troubles really tell us

View photos The candidate speaking at Trump SoHo Hotel in New York City on June 22. (Photo: Drew Angerer/Getty Images) More More incredible news for the Donald Trump juggernaut! After a 10-day stretch in which Trump found himself rebuked by Republican leaders, plummeting in polls and firing his much-maligned campaign manager , news broke that, according to public filings, his campaign now had about $1.3 million in the bank. This is awesome if you're running for a House seat in, say, Maine. It's slightly less awesome if you're running for president. How much less awesome? About 40 times less than what Hillary Clinton has at her disposal — not counting outside groups that have been revving up on her behalf for at least a year. So, yeah, a lot less awesome. This really is something, considering that all through the primaries Trump bragged about how he was so rich you wouldn't believe and how he was the only guy on stage who didn't need to ask for money.

Read full article from What Trump's money troubles really tell us


Supreme Court upholds affirmative action program



Supreme Court upholds affirmative action program

What was contested is the second method — a topping-off of each freshman class by focusing on a variety of factors, from special talents and extracurricular activities to socioeconomics, race and ethnicity. Those last factors are used to produce what the school calls "diversity within diversity" — a representative mix of minority students, rather than just those from segregated communities with similar backgrounds and experiences.


Read full article from Supreme Court upholds affirmative action program


头条文章



头条文章


Read full article from 头条文章


Watch out, WebMD: Google's teamed with leading doctors to provide vetted online medical advice | PCWorld



Watch out, WebMD: Google's teamed with leading doctors to provide vetted online medical advice | PCWorld

    Jun 20, 2016 12:58 PM Feeling nauseous? Perhaps a bit feverish? Google's launching a new feature on mobile and its Google search app that promises to provide answers without forcing you to dig through dozens of overwhelming (and possibly misleading) medical forums, let alone consult established sites like WebMD.  In the coming days, when you ask Google about your symptoms, the search engine will return a list of related conditions. For instance, if you search for "headache on one side," Google will offer up a list of informational cards with possible answers for what's ailing you. Tap a card, and it'll provide further information on the condition and treatment. Google takes pains to emphasize that it's trying to make it easier for you to find good medical information on the web, but it's also making sure you don't use the web as a substitute for professional advice. In its blog post ,

Read full article from Watch out, WebMD: Google's teamed with leading doctors to provide vetted online medical advice | PCWorld


揭秘百万人围观的Facebook视频直播



揭秘百万人围观的Facebook视频直播

高可用架构 微信号 ArchNotes 功能介绍 高可用架构公众号。 几个月前,我们开始推出 Facebook Mentions 的 Live 功能,该功能让认证后的公众人物可以通过 Mentions 对其 Facebook上 的粉丝进行视频直播。我们在这次部署中学到了很多,并且我们已经开始测试 Facebook 用户使用的视频直播分享功能,第一步我们先从美国使用 iPhone 的这一小部分用户开始测试。 为 Facebook 构建视频直播是一项具有挑战性的大规模工程活动。在 Facebook Mentions 的 Live 功能上,我们必须解决巨大的流量峰值问题。Facebook 上的公众人物粉丝可能多达百万,这些粉丝全都想要在同一时间观看视频;我们还有一个目标,就是创造均衡负载的新办法。为了开始向更多的人推出视频直播,我们通过允许 RTMP 进行回放,从而把直播的延迟压缩到几秒钟。我们希望这些低延迟的直播会改善用户体验,让直播者和观看者之间更高的互动性。在这篇文章中,我们将粗略地看一下我们在每次发布时解决的问题,我还将向你解释我们为负载均衡和 RTMP 实现问题所选择的解决方案。 解决"惊群效应"问题 可以说,防止过载的最好方法就是不让负载穿过大门。与其让客户端直接和直播流服务器连接,我们让边缘缓存(edge caches)的网络分布到全局。 在我们的实现中,一个视频直播被分割成了 3 秒的 HLS 段。显示直播的视频播放器会继续请求这些段。边缘数据中心的一个 HTTP 代理会处理段请求,该数据中心会检查这个段是否已经存在于一个边缘缓存中。如果在缓存中,它就会被返回。如果不在,代理就会向源缓存发出 HTTP 请求,而源缓存是另一个具有相同架构的缓存层。 如果段不在源缓存中,就需要向处理这个特定视频流的服务器请求。 这个解决方案很不错,但是当你处于我们这样的规模时就会发生一些泄露——约有1.

Read full article from 揭秘百万人围观的Facebook视频直播


House Democrats Stage a Sit-in on the House Floor on Gun Control - The Atlantic



House Democrats Stage a Sit-in on the House Floor on Gun Control - The Atlantic

I'm not sure how much it falls in line with regulations, but sit-in members just held a vote to suspend the rules and thus keep phones and recording devices on through their speeches.


Read full article from House Democrats Stage a Sit-in on the House Floor on Gun Control - The Atlantic


现在应该学习哪些语言和框架-软件开发-鸡啄米



现在应该学习哪些语言和框架-软件开发-鸡啄米

大趋势 语言和平台 Python 3.5 在今年发布了,带来了很多新特性 比如 Asyncio,为你带来了类似 node.js 的事件机制,还有type hints。 鉴于Python 3 终于真正地火起来了我们强烈建议你替换掉 Python 2。几乎所有的库都已经支持 Python 3 了,所以现在是一个升级历史遗留代码的好时机。 PHP 7 是一个重要的新版本,这个版本修复了很多问题并且带来了新特性和性能提升(看看概览) 。 PHP 7 大约比 PHP 5.6 快2倍, 这对一些大型项目还有WordPress 和 Drupal之类的CMS系统影响很大。 我们强烈推荐 PHP之道,已经更新到最新的PHP7版本。 如果你需要更快的速度并且不介意换一个解释引擎的话,可以试试Facebook在用的 HHVM。 JavaScript 也以ES2015 标准 (大家通常叫做 ES6)的形式发布了更新。 为我们带来了激动人心的新功能。 感谢大多数浏览器版本的快速更新, 对 ES2015 的支持已经非常棒了,并且还有 Babel.js 这样的工具可以让你的新代码跑在低版本浏览器上。 Node.js 在这一年变化很多,开发者社区曾经分裂成 Node.js 和 io.js,然后又再度合并。 经历过这些之后的结局就是我们得到了一个有很多代码贡献者积极维护的项目,并且拥有了两个版本的 Node : 一个稳定的LTS (长期支持) 版本,这个版本注重稳定性,比较适合长期项目和大公司,和一个非长期支持但是最快实现新特征的版本。 Swift 2 在今年初发布了。 这是 Apple 出品的旨在简化 iOS 和 OS X 开发的现代编程语言。 几周前, Swift 正式开源并已经兼容 Linux。这意味着你可以用它来编写服务端应用了。 Go 1.

Read full article from 现在应该学习哪些语言和框架-软件开发-鸡啄米


关于面试的那些事儿(1)



关于面试的那些事儿(1)


Read full article from 关于面试的那些事儿(1)


Spring 4.3 的新功能和增强 - waylau的个人页面 - 开源中国社区



Spring 4.3 的新功能和增强 - waylau的个人页面 - 开源中国社区


Read full article from Spring 4.3 的新功能和增强 - waylau的个人页面 - 开源中国社区


Buttercola: Even Iterator



Buttercola: Even Iterator

设计iterator, input是一个遍历1到N的iterator,你设计的iterator只返回偶数。

Read full article from Buttercola: Even Iterator


注意!今天去Costco要换卡!Visa随便刷,运通不能用了!



注意!今天去Costco要换卡!Visa随便刷,运通不能用了!


Read full article from 注意!今天去Costco要换卡!Visa随便刷,运通不能用了!


Donald Trump's changing gun positions - CNNPolitics.com



Donald Trump's changing gun positions - CNNPolitics.com

However, Trump on Sunday modified his position, saying on ABC that he "understands exactly" the NRA's concerns and expressed his own.
"A lot of people are on the list that really maybe shouldn't be on the list," he said, "and their (Second Amendment) rights are being taken away."

Read full article from Donald Trump's changing gun positions - CNNPolitics.com


java - How exactly works the Spring bean post processor? - Stack Overflow



java - How exactly works the Spring bean post processor? - Stack Overflow

I am studying for the Spring Core certification an I have some doubts about how Spring handle the beans lifecycle and in particular about the bean post processor.


Read full article from java - How exactly works the Spring bean post processor? - Stack Overflow


Registering, unregistering, scheduling, and unscheduling Task Scheduler at runtime in Spring Framework 3.0/3.1 (2010476) – All Help & Support



Registering, unregistering, scheduling, and unscheduling Task Scheduler at runtime in Spring Framework 3.0/3.1 (2010476) – All Help & Support

Registering, unregistering, scheduling, and unscheduling Task Scheduler at runtime in Spring Framework 3.0/3.1 (2010476)

Purpose

On Spring Framework 3.0 and 3.1 reference documents, most examples on scheduling and registering Task Schedulers are done using the Spring Framework configuration. For example: 


Read full article from Registering, unregistering, scheduling, and unscheduling Task Scheduler at runtime in Spring Framework 3.0/3.1 (2010476) – All Help & Support


java - Should I declare Jackson's ObjectMapper as a static field? - Stack Overflow



java - Should I declare Jackson's ObjectMapper as a static field? - Stack Overflow

Although ObjectMapper is thread safe, I would strongly discourage from declaring it as a static variable, especially in multithreaded application. Not even because it is a bad practice, but because you are running a heavy risk of deadlocking. I am telling it from my own experience. I created an application with 4 identical threads that were getting and processing JSON data from web services. My application was frequently stalling on the following command, according to the thread dump:

Map aPage = mapper.readValue(reader, Map.class);

Beside that, performance was not good. When I replaced static variable with the instance based variable, stalling disappeared and performance quadrupled. I.e. 2.4 millions JSON documents were processed in 40min.56sec., instead of 2.5 hours previously.


Read full article from java - Should I declare Jackson's ObjectMapper as a static field? - Stack Overflow


Solr - User - [Schema API] EmbeddedSolrServer Test



Solr - User - [Schema API] EmbeddedSolrServer Test

EmbeddedSolrServer is really just for dealing with embedded SolrCore
objects.  It doesn't have ay of the other HTTP related plumbing
assocaited with it -- which is why it can't be used for replication and/or
cloud features, let alone the RESTLet based endpoints.

if you want to write a test that leverages the SchemaAPI, your best bet is
to take advantage of the baseclass provided with solr's test framework...

Read full article from Solr - User - [Schema API] EmbeddedSolrServer Test


Subresources and Runtime Resource Resolution - The Java EE 6 Tutorial



Subresources and Runtime Resource Resolution - The Java EE 6 Tutorial

A subresource locator returns an object that will handle an HTTP request. The method must not be annotated with a request method designator. You must declare a subresource locator within a subresource class, and only subresource locators are used for runtime resource resolution.


Read full article from Subresources and Runtime Resource Resolution - The Java EE 6 Tutorial


emacs-document/代码之外:项目规划.org at master · lujun9972/emacs-document



emacs-document/代码之外:项目规划.org at master · lujun9972/emacs-document

在"代码之外"系列文章中, 我会回顾那些使我开发更有效率的工具与流程. 我希望通过分享我的经验,可以从你们获得反馈,从而改进我工作的方式.

今天的主题是关于项目计划的. 其过程包括将项目分解为任务以及评估完成任务所需要的付出. 该过程的产物可以作为客户提案,可以用于为老板估计成本甚至可以作为项目文档的起点.

文件格式以及工具很重要

若从这段艰苦的过程中我只学到一件事情的话,那一定是:我现在所使用的工具不代表以后也会用. 也许是因为出现了更好的工具,也许我不得不换一个操作系统,而在该操作系统上,这个工具不再能用.

我会尽量避免使用私有格式的二进制文件. 这是我的第一要则:

规则 1: 经可能使用纯文本格式. 无论你使用的哪个平台,你都可以阅读及修改文本文件. 若恰好你所用时的平台载有许多上好的命令行工具(例如UNIX系的操作系统), 这意味着你已经有用了一个强大的查找,搜索以及转换文本文件的系统.

文本文件rock, 那么用那个工具来编辑它们最好呢? 作为一名开发者,你对使用文本编辑器应该并不陌生. 事实上,这应该你最高效,最适应的工具才对. 若你只能精通一件事,那就是精通使用你的文本编辑器.


Read full article from emacs-document/代码之外:项目规划.org at master · lujun9972/emacs-document


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