Skip to main content

Posts

Showing posts from August 13, 2017

最大子数列问题

在计算机科学中,最大子数列问题的目标是在数列的一维方向找到一个连续的子数列,使该子数列的和最大。例如,对一个数列 −2, 1, −3, 4, −1, 2, 1, −5, 4,其连续子数列中和最大的是 4, −1, 2, 1, 其和为6。 该问题最初由布朗大学的Ulf Grenander教授于1977年提出,当初他为了展示数字图像中一个简单的最大似然估计模型。不久之后卡内基梅隆大学的Jay Kadane提出了该问题的线性算法。(Bentley 1984)。 Kadane算法[编辑] Kadane算法扫描一次整个数列的所有数值,在每一个扫描点计算以该点数值为结束点的子数列的最大和(正数和)。该子数列有可能为空,或者由两部分组成:以前一个位置为结束点的最大子数列、该位置的数值。可用如下代码表示,这里用到了Python: def max_subarray(A):     max_ending_here = max_so_far = A[0]     for x in A[1:]:         max_ending_here = max(x, max_ending_here + x)         max_so_far = max(max_so_far, max_ending_here)     return max_so_far 该问题的一个变种是:如果数列中含有负数元素,不允许返回长度为零的子数列。该问题可用如下代码解决: def max_subarray(A):     max_ending_here = max_so_far = A[0]     for x in A[1:]:         max_ending_here = max(x, max_ending_here + x)         max_so_far = max(max_so_far, max_ending_here)     return max_so_far 这种算法稍作修改就...

What is an All-Hands Meeting?

An All-Hands Meeting is generally an organization wide business meeting in which an executive report is made to employees and stake holders. All-Hands meetings are often held on a regular basis as a means of keeping a large group of people up to date on important events and milestones. All-Hands Meetings can be held in conference rooms, corporate cafeterias, hotel ballrooms and across many time zones and continents. An effective All-Hands Meeting usually begins with an important message and includes some form of question and answer capability. The term "Town Hall" meeting is often used interchangeably with All-Hands meeting however a Town Hall meeting is more question and answer based while All-Hands meetings are generally more focused on conveying a message and making a key presentation. ref: http://www.video-conferencing.com/definition/all-hands-meeting.html

[Leetcode 10] Regular Expression Matching