Home > other >  The recent problems higher peaks
The recent problems higher peaks

Time:09-21

In Python solution:
A=array (a0, a1, a2, a3, a4,..., the an - 1) on behalf of each peak peak height, is given in the order they appear in the mountains, with each partition method find higher peaks and mountain peaks, to the left to the right index higher peak position, for example:
Input: A=,3,2,7,4,9 [1]
Output:
L=[None, None, 2, None, 3, None] R=[1, 3, 3, 5, 5, None]

CodePudding user response:

How much is each height of the mountain?

CodePudding user response:

reference 1st floor paullbm response:
how much is each height of the mountain?

Example is,3,2,7,4,9 [1]

CodePudding user response:

refer to the second floor sinat_32485643 response:
Quote: refer to 1st floor paullbm response:
how much is each height of the mountain?

Example is,3,2,7,4,9 [1]


Then you this sample in?

Input: A=,3,2,7,4,9 [1] # if this respectively represent A highly
Output:
L=[None, None, 2, None, 3, None] R=[1, 3, 3, 5, 5, None]

# the height is 3 to the right of the top should not be 9?

CodePudding user response:

reference paullbm reply: 3/f
Quote: refer to the second floor sinat_32485643 response:

Quote: refer to 1st floor paullbm response:
how much is each height of the mountain?

Example is,3,2,7,4,9 [1]


Then you this sample in?

Input: A=,3,2,7,4,9 [1] # if this respectively represent A highly
Output:
L=[None, None, 2, None, 3, None] R=[1, 3, 3, 5, 5, None]

# the height is 3 to the right of the top should not be 9?

Is to find higher than their recent peaks

CodePudding user response:

Sinat_32485643
reference 4 floor response:
Quote: refer to the third floor paullbm response:
Quote: refer to the second floor sinat_32485643 response:

Quote: refer to 1st floor paullbm response:
how much is each height of the mountain?

Example is,3,2,7,4,9 [1]


Then you this sample in?

Input: A=,3,2,7,4,9 [1] # if this respectively represent A highly
Output:
L=[None, None, 2, None, 3, None] R=[1, 3, 3, 5, 5, None]

# the height is 3 to the right of the top should not be 9?

Is to find higher than their recent peaks


That should be 7

CodePudding user response:

reference 5 floor paullbm reply:
Quote: refer to 4th floor sinat_32485643 response:

Quote: refer to the third floor paullbm response:
Quote: refer to the second floor sinat_32485643 response:

Quote: refer to 1st floor paullbm response:
how much is each height of the mountain?

Example is,3,2,7,4,9 [1]


Then you this sample in?

Input: A=,3,2,7,4,9 [1] # if this respectively represent A highly
Output:
L=[None, None, 2, None, 3, None] R=[1, 3, 3, 5, 5, None]

# the height is 3 to the right of the top should not be 9?

Is to find higher than their recent peaks


That should be 7

7 indexes

CodePudding user response:

 a=,3,2,7,4,9 [1] 

L=[]
R=[]

For I in range (0, len (a)) :
L1, R1=a [, I], a [I + 1]
For k in range (0, len (L1) :
If L1 [k] & gt; [I] a:
L.A. ppend (k)
Break
The else:
L.A. ppend (None)
In the range for m (0, len (R1) :
If R1 [m] & gt; [I] a:
Of state Richard armitage ppend (I + m + 1)
Break
The else:
Of state Richard armitage ppend (None)

Print (L)
Print (R)

CodePudding user response:

refer to the eighth floor chuifengde response:
 a=,3,2,7,4,9 [1] 

L=[]
R=[]

For I in range (0, len (a)) :
L1, R1=a [, I], a [I + 1]
For k in range (0, len (L1) :
If L1 [k] & gt; [I] a:
L.A. ppend (k)
Break
The else:
L.A. ppend (None)
In the range for m (0, len (R1) :
If R1 [m] & gt; [I] a:
Of state Richard armitage ppend (I + m + 1)
Break
The else:
Of state Richard armitage ppend (None)

Print (L)
Print (R)

First of all, your code returned is not the more recent peak, if a=8 [3], for 3 more recent peak on the left is four indexes, but use your method returns will be 8 indexes, and then not used partition method,

CodePudding user response:

The first question to say, the range (0, len (L1) : changing range (len (L1), 1, 1) is
Second question partition method, is divided into subproblems have intersection, it is better to use cycle to solve
  • Related