• Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
CODE OF GEEKS

We at CODE OF GEEKS, aim at providing best and quality content for our users at no extra cost.

    • Study Materials – Company wise
      • Infosys Archive
      • Accenture Archive
      • AMCAT Archive
      • Capgemini Archive
      • Cisco Archive
      • CoCubes Archive
      • Cognizant(CTS) Archive
      • Dell Archive
      • Deloitte Archive
      • DXC Archive
      • Goldman Sachs Archive
      • Hexaware Technologies Archive
      • LTI Archive
      • MindTree Archive
      • TCS Archive
      • Virtusa Archive
      • Wipro Archive
    • Interview Preparation – E Books
      • C Interview Questions
      • Data Structures Interview Questions
      • DBMS Interview Questions
      • HR Interview Questions
      • Java Interview Questions
      • Operating System Interview Questions
      • Python Interview Questions
      • SQL Query Interview Questions
    • Programming
      • C Programming MCQs
      • C Code Snippets – Output Questions
      • Python Code Snippets – Output Questions
    • Aptitude
      • Verbal Ability for Placements
      • Quant for Placements
    • Register
    • Login
  • [email protected]
  • ..
Login / Register
Apply Now
CODE OF GEEKS
CODE OF GEEKS
  • Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
0

Cart

Longest SubArray

  • March 1, 2020
  • CODE OF GEEKS
  • 8

Consider an array A. Your job is to find longest subarray in which elements greater than x are more than elements not greater than x

Input

1. size of array , x
2. Array elements

Example

Input

5 5
4 5 7 8 3

Output

3

Explanation

Subarray formed : [5,7,8]



Tags: hack with infy coding questionshackwithinfy coding problemshackwithinfy coding questions
  • Previous Tree Edges
  • Next m*n board

8 comments on “Longest SubArray”

  1. Name* says:
    March 3, 2020 at 9:39 am

    please share more examples for this problem

    Reply
    1. nagireddy says:
      March 10, 2020 at 9:19 am

      j=list(map(int,input().split(” “)))[0:2]
      n=j[0]
      e=j[1]
      l=list(map(int,input().split(” “)))[0:n]
      k=[]
      for i in l:
      if(i>=e):
      k.append(i)
      print(len(k))

      Reply
      1. Anonymous says:
        March 10, 2020 at 5:11 pm

        It is wrong answer

        Reply
        1. Shrutik Haribhau Gumate says:
          March 21, 2020 at 9:05 am

          #checkout this one
          n,k=map(int,input().split())
          l=list(map(int,input().split()))
          subarray=[l[i:j] for i in range(n) for j in range(i+1,n+1) if l[i]>=5]
          res=0
          for i in subarray:
          for j in i:
          if j<k:break;
          else:
          if res<len(i):res=len(i)
          print(res)

          Reply
      2. Ajit shiva says:
        March 14, 2020 at 5:33 am

        It is a dp problem

        Reply
  2. smit says:
    March 29, 2020 at 5:59 pm

    #include
    using namespace std;

    int main(){
    int n,x;
    cin>>n>>x;
    int a[n];
    for(int i=0; i>a[i];
    int max=0;
    int maxCurr=0;
    for(int i=0; i<n; i++){
    if(a[i]<x)
    maxCurr=0;
    maxCurr++;
    if(max<maxCurr)
    max=maxCurr;
    }
    cout<<max;
    return 0;
    }

    Reply
  3. Mrunali Shirke says:
    April 26, 2021 at 2:53 pm

    n = int(input(“enter the value of n: “))
    x = int(input(“enter the value of x: “))
    array = list(map(int, input(“Enter a array: “).split()))
    new_array = []
    for i in range(n):
    if array[i] <= x:
    new_array.append(array[i])
    print(len(new_array))

    Reply
  4. AK says:
    May 4, 2021 at 12:16 pm

    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    arr=[]
    i=0
    for i in range(0,len(l)):
    j=len(l)-1
    while i != j:
    arr.append(l[i:j])
    j=j-1
    for i in arr:
    if len(i) >= len(l)/2:
    a = all(number >=k for number in i)
    if a:
    print(i)

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CODE OF GEEKS

Subscribe to Newsletter

CODE OF GEEKS

Learn | Code | Achieve

Reach us

[email protected]
We at CODE OF GEEKS, aim at providing quality content to our users at no cost.
CODE OF GEEKS

Important Pages

About us
Advertise
Privacy Policy
Terms and Conditions

Placements – Study Materials

TCS NQT     Wipro     CapGemini
Accenture     MindTree     CTS
DXC     Hexaware Technologies     AMCAT
CoCubes     Goldman Sachs     Dell
Cisco     Deloitte     Virtusa     LTI     Infosys   

Courses

  • Mail Us
  • Login/Register

Recent Posts

TCS Reasoning 2021
  • October 4, 2021
TCS Verbal 2021
  • October 4, 2021

Copyright 2021 CODE OF GEEKS. All Rights Reserved.

  • →