World Languages, asked by subodhkhirade187, 2 months ago

Given a list numberlist() of integer numbers
that have size N and one another number N2,
also given the size S(integer number) of the
subset. The task is to find the number N2
present in every non overlapping subset of size
S in numberlist. If number N2 is present in
every subset print 1 otherwise print 0.
For Example:
Example-1:
Input:
Value of Ni.e. size of numberList[],
12
(20.1,6,8,13,20,1,7,20,13,16,20) - values of
numberlist[). Each value separated by a new
line.
20 - value of N2
value of Sle, size of subset.​

Answers

Answered by 485golu
0

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int N =sc.nextInt();

int numberList[]=new int[N];

for(int i=0;i<N;i++){

numberList[i]=sc.nextInt();

}

int N2 =sc.nextInt();

int s =sc.nextInt();

int x=N/s;

int c=0;

int y=N%s;

for(int i=0;i<(N-y);i=i+3){

if(numberList[i]==N2 || numberList[i+1]==N2 ||numberList[i+2]==N2)

c++;

}

System.out.println(c);

if(x==c)

System.out.println(1);

else

System.out.println(0);

}

}

Answered by sondhiya79095
0

Answer:

n = int(input())

l = list(map(int,input().split()))

Search = int(input())

steps = int(input())

found = False

for i in range(0,n,steps):

  found = False

  for j in range(i,i+steps):

     if j<n:

        if(l[j]==search):

           found = True;

     if found:

        continue

     else:

        print(0)

        break;

if found:

  print(1)

Explanation:

Similar questions