fork download
  1.  
Success #stdin #stdout 0.09s 14140KB
stdin
# Define the array
arr = [1.5, 2.3, 1.1, 0.9]
# Initialize the counter
count = 0
# Initialize the list to store indices
indices = []

# Iterate through the array, excluding the last element
for i in range(len(arr) - 1):
    # If the current element is greater than its right - hand neighbor
    if arr[i] > arr[i + 1]:
        # Add the index of the current element to the indices list
        indices.append(i)
        # Increment the counter by 1
        count += 1

# Print the indices of elements greater than their right - hand neighbors and the corresponding element values
print(f"In the array {arr}, the indices {indices} correspond to elements {[arr[idx] for idx in indices]} which are greater than their right - hand neighbors.")
# Print the number of such elements
print(f"In the array {arr}, the number of such elements (K) is {count}.")
stdout
Standard output is empty