Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» templet program
SMARKET SOLUTION EmptySun May 14, 2017 11:57 am by akarshsomani

» IP6: Write a C++ program that uses the concept of hybrid inheritance.
SMARKET SOLUTION EmptySun May 14, 2017 10:55 am by iamdsc_0410

» Overloading new and delete operator program
SMARKET SOLUTION EmptySat May 13, 2017 7:29 am by akarshsomani

» Constructos and Destructors assignment question:CD-3
SMARKET SOLUTION EmptyThu May 11, 2017 1:57 pm by Prateek Gupta

» Program related to Object Slicing : Why the output is not coming In Base a=2 ?
SMARKET SOLUTION EmptyFri May 05, 2017 7:36 am by akarshsomani

» Program given by sir i.e given in Reema Thareja on Overloading of new and delete operators is not working . Debug it !!
SMARKET SOLUTION EmptyMon May 01, 2017 9:11 am by iamdsc_0410

» constructor and destructor assignment solutions
SMARKET SOLUTION EmptyMon Apr 24, 2017 8:10 am by akarshsomani

» class and objects assignment solutions.
SMARKET SOLUTION EmptyFri Apr 21, 2017 9:01 pm by iamdsc_0410

» SMARKET SOLUTION
SMARKET SOLUTION EmptyTue Apr 18, 2017 6:33 pm by iamdsc_0410

Keywords

Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest

None

[ View the whole list ]


Most users ever online was 7 on Tue Jun 02, 2020 6:34 am
RSS feeds


Yahoo! 
MSN 
AOL 
Netvibes 
Bloglines 


SMARKET SOLUTION

Mon Apr 17, 2017 5:31 pm by akarshsomani

It ran only of 10 points.please share better solutions

Code:
import java.util.Scanner;
 
class smarket {
   public static void  main(String args[])
   {
      Scanner sc=new Scanner(System.in);
      
      int t=sc.nextInt();
      while(t-->0)
      {
         
         int n=sc.nextInt();
         int q=sc.nextInt();
         int a[]=new int[n];
         for(int i=0;i<n;i++)
         {
            a[i]=sc.nextInt();
         }
         while(q-->0)
         {
            int l=sc.nextInt();
            int r=sc.nextInt();
            int k=sc.nextInt();
            int count=0,c=0,copy;
            for(int i=l-1;i<r;i++)
            {
               copy=a[i];
               c=0;
               while(copy==a[i])
               {
                  c++;
                  i++;
                  if(i==r)
                  {
                     break;
                  }
                  else
                  {
                     if(copy==a[i])
                     {
                        c++;
                        i++;
                        if(i==r)
                        {
                           break;
                        }
                     }
                  }
               }
               if(c>=k)
               {
                  count++;
               }
               i--;
            }
            System.out.println(count);
         }
      }
   }
}


Comments: 1

Social bookmarking

Social bookmarking reddit      

Bookmark and share the address of Coding Discussions on your social bookmarking website

April 2024
MonTueWedThuFriSatSun
1234567
891011121314
15161718192021
22232425262728
2930     

Calendar Calendar

Most active topic starters
akarshsomani
SMARKET SOLUTION Vote_lcapSMARKET SOLUTION Voting_barSMARKET SOLUTION Vote_rcap 
Prateek Gupta
SMARKET SOLUTION Vote_lcapSMARKET SOLUTION Voting_barSMARKET SOLUTION Vote_rcap 
iamdsc_0410
SMARKET SOLUTION Vote_lcapSMARKET SOLUTION Voting_barSMARKET SOLUTION Vote_rcap 
Arjun1810
SMARKET SOLUTION Vote_lcapSMARKET SOLUTION Voting_barSMARKET SOLUTION Vote_rcap 

Statistics
We have 10 registered users
The newest registered user is shivendra

Our users have posted a total of 44 messages in 19 subjects