You are not logged in. Please login at www.codechef.com to post your questions!

×

What is wrong in my approach in Second largest Element question of ENCODER, NIT Kurukshetra

The question is here --> Question and this is my code in python3:

for i in range(int(input())):

x,y = map(int,input().split())
arr = [int(i) for i in input().split()]
i=0
curr = 'N'
all_m = 0
count=0
ind=0
while i<len(arr):
    i = ind
    while i<len(arr):
        if arr[i] >y and arr[i]!=curr:
            if curr!='N':
                ind = arr.index(curr)+1
                all_m = max(all_m,count)
                curr = arr[i]
                count= i - (ind-1)
            else:
                curr = arr[i]
                count+=1
        else:
            count+=1
        i+=1
all_m = max(all_m,count)
print(all_m)

asked 27 Oct, 11:41

anonymous_wolf's gravatar image

4★anonymous_wolf
11
accept rate: 0%

edited 27 Oct, 11:42

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×820
×246
×68

question asked: 27 Oct, 11:41

question was seen: 13 times

last updated: 27 Oct, 11:42

Related questions