vejon
BAN USER
passionate to code
- 0of 0 votes
Answers
- vejon in United StatesGiven a number n, make a set of m integers such that the integers lie between [1, n] and the sum of two integers should produce an integer which is in the set. Eg. **Input** n=20, m=5 **Output** [3, 6, 11, 14, 17]
| Report Duplicate | Flag | PURGE
ThoughtWorks Applications Developer - 0of 0 votes
AnswerGiven a string of size n consisting of 0s and/or 1s.you have to perform k queries and there are two types of queries possible.
- vejon in United States
"1"(without quotes): Print length of the longest substring with all '1'.
"2 X"(without quotes): where X is an Integer between 1 to n.In this query, you will change character at Xth position to '1' (it is possible that the character at ith position was already '1')
Input Format:
First Line of input contains n and k, where n is string length and k is the number of queries.
Next line contains a string of 0's and/or 1's of length n.
Each of next k lines contains query of any one type (i.e 1 or 2).
Output Format: For each query of type 1, print in new line the maximum size of subarray with all 1's.
Example Input:
5 7
00000
1
2 3
1
2 5
1
2 4
1
Example Output:
0
1
1
3| Report Duplicate | Flag | PURGE
Google Software Developer
#include<bits/stdc++.h>
using namespace std;
int a[1000<<2];
int main()
{
long long int i,j,k,m,n;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i=i+2)
{
if(i==0)
{
if(a[i]<a[i+1])
{
swap(a[i],a[i+1]);
}
}
if(a[i]<a[i+1])
{
swap(a[i],a[i+1]);
}
if(a[i]<a[i-1])
{
swap(a[i],a[i-1]);
}
}
for(i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
}
#include<bits/stdc++.h>
using namespace std;
int a[1000<<2];
int main()
{
long long int i,j,k,m,n;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i=i+2)
{
if(i==0)
{
if(a[i]<a[i+1])
{
swap(a[i],a[i+1]);
}
}
if(a[i]<a[i+1])
{
swap(a[i],a[i+1]);
}
if(a[i]<a[i-1])
{
swap(a[i],a[i-1]);
}
}
for(i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
}
Repleroydperry, Backend Developer at AppNexus
I am from the USA. I am 27 year old. I drive the train for my company Monk Home Funding ...
Repjoycejflora, Android Engineer at ABC TECH SUPPORT
I am excited about cooperation and interesting projects. Last year I work for a person who provides the black magic ...
Repcarleywcote, Problem Setter at Baidu
I am a Photographer in Dallas. I Capture images as directed, taking all aspects into consideration, including outside lighting, shadows ...
Reprobinroi335, Android test engineer at ABC TECH SUPPORT
I believe the deepest changes you can make to improve your quality of life. how to break a family curse ...
Repgradyjvierra, Animator at Alliance Global Servies
Je suis Grady de Phoenix USA. Je travaille en tant que technicien de laboratoire clinique dans la société Samuels Men ...
Repemilymross903, Area Sales Manager at ASAPInfosystemsPvtLtd
Hello, I am Emily and I live in Liberty. I am working as Fitness trainers and I instructors lead, instruct ...
Repnancysimms14, Backend Developer at ASAPInfosystemsPvtLtd
I am Nancy from California,Handling project development and documentation is my job. Passionate determined.Looking for an open project ...
Repanitajrouse, Kuwait airways reservations at American Airlines
I am Anita from Hastings USA. I am working as a manager in Sofa Express company. I Managed the schedules ...
Repharoldknopph, Android test engineer at AMD
I am a publicity writer from Atlanta USA . I create an intended public image for individuals, groups, or organizations. I ...
seat should have screen id too
- vejon June 04, 2019