ARTS punch Week 14

A:Maximum Sum of 3 Non-Overlapping Subarrays  

题目:In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.

Each subarray will be of size k, and we want to maximize the sum of all 3*k entries.

Return the result as a list of indices representing the starting position of each interval (0-indexed).

If there are multiple answers, return the lexicographically smallest one.

The meaning of problems: Given a positive integer array the nums disorder, a length of n, does not overlap find three sub-arrays of length k is obtained and a maximum, corresponding to the return sub-arrays starting position

Ideas: the array nums accumulated data, recording the results in the array when the data reaches k, the size of the results for n-k + 1, each coupled with the current number after subtracting the starting position,

Ensure that the result k is the number of results and, to 0 to k-1,1 k ..., NK to n-1, then use a storage array left, left to right, and the number k the maximum value of the starting position,

Position of the maximum of the first occurrence of recording, using an array to store the right from right to left and the number k of the starting position of the maximum, the position of the last occurrence of the maximum recording,

Then to find k from a n-2k element between the sub-array as the start position of the middle, according to the number of the middle, and the possibilities to find the maximum of three sub-array, k is a reduced left intermediate position, the intermediate position to the right plus k,

Comparing the maximum results.

Program: https://leetcode.com/submissions/detail/237089350/

R: http://open.163.com/movie/2010/12/9/J/M6UTT5U0I_M6V2TJ49J.html , "balanced search tree" structure of the search tree can not balance its operating efficiency will be greatly reduced.

It introduced the balanced tree algorithm - a red-black tree. From the operational efficiency of the red-black tree search and updates are O (logn), explains how to find and how to rotate the node is updated, characteristic red-black tree:

1. The nature of the node is red or black.
2. The nature of the root node is black.
3 Properties of two child nodes of each node are black red. (Red can not have two consecutive nodes on all paths from the root to each leaf)
4. The nature from any node to all leaves of each path contains the same number of black nodes.

T: to simplify the code through techniques java class reflection mechanism: by acquiring a set of attributes of the object class may be utilized to read and manipulate data assignment that may be used for some other nodes in the node xml Case,

Return results or custom format:

Field [] field = model.getClass () getDeclaredFields ();. // get all the attributes of the entity class, returns an array of Field

String name = field [j] .getName (); // Get the name of the attribute
String nameTem name.substring = (0,. 1) .toUpperCase () name.substring + (. 1);
// configuration corresponding to the method name
Method m ;. = model.getClass () getMethod ( "gET" + nameTem)
// calls the getter method to get the property value
Object value = m.invoke (model); 

S: Sharing "How more than most people." - Left mouse ear, are discussed in the dimension and leadership skills, how more than most people.

Skills: people skills are cognitive Start, then through schools, books or training to convert these bits and pieces of knowledge into a more systematic knowledge, skills and should be converted into knowledge,

We need training and practice, this can be done from the cognitive skills to knowledge and then to the conversion, this process takes time and effort, most people will fall here, you need to have enough patience.

Leadership: To have leadership or influence, and the need to match the ambition and high standards need to find their strengths and talents, to flourish, to find their own points of interest and career,

Establish a high-level habits and methods, hard work, do not give up easily.

Guess you like

Origin www.cnblogs.com/wujunjie-Blog/p/11074331.html