Sort by

recency

|

119 Discussions

|

  • + 1 comment

    The expected output for case 0 and case 11 is, 2500100000 Which is the greater than the max int value in java. Did anyone got it working?

  • + 0 comments

    Is it just me or should test Case 0 and 11 should have zero as the answer? the queestion state you want strcitly greater than not equal? Since 0 and 11 are just huge inputs of the same number there is no a_j or a_k that is greater than a__i

  • + 0 comments

    hello, this is really weird. This solution scores 100% Yet if you test it with inputs : 5 2 1 1 1 5 It should return 5, and yet it returns 0

    def solve(arr):
        left = []
        right = []
        n = len(arr)
        for i,e in enumerate(arr):
            if i==0 or e>= arr[i-1]:
                left.append(0)
            else:
                left.append(i)
            if i== n-1 or e>=arr[i + 1]:
                right.append(0)
            else:
                right.append(i+2)
        return max([left[i]*right[i] for i in range(n)])
    
  • + 1 comment

    This is my solution in python3

    import math
    import os
    import random
    import re
    import sys
    from typing import List
    
    def optimal(array: List):
        returned_values_left: list[int] = []
        returned_values_right: list[int] = []
        for index, item in enumerate(array):
            if index == 0:
                returned_values_left.append(0)
            else:
                if item < array[index - 1]:
                    returned_values_left.append(index)
                else:
                    returned_values_left.append(0)
    
            if index == len(array)-1:
                returned_values_right.append(0)
            else:
                if item < array[index + 1]:
                    returned_values_right.append(index + 2)
                else:
                    returned_values_right.append(0)
        return [returned_values_left,returned_values_right]
        
    #
    # Complete the 'solve' function below.
    #
    # The function is expected to return an INTEGER.
    # The function accepts INTEGER_ARRAY arr as parameter.
    #
    
    def solve(arr):
        # Write your code here
        value = sys.maxsize * -1
        [left,right] = optimal(arr)
    
        for position in range(len(arr)):
            new_value = left[position] * right[position]
            if new_value > value:
                value = new_value
    
        return value
    
  • + 0 comments

    i have 4 test cases failing in python . Kudos to who ever got it working for all test cases and thanks for sharing the solution.Good to know there's a solution.

    Gist for 4 failing test cases