Practo Interview Question for Development Support Engineers

Country: United States
Interview Type: Phone Interview

Comment hidden because of low score. Click to expand.
0
of 0 vote

You've asked for "pairs" when depending on the input A and B you may have arbitrary n-tuples. Could you please clarify the problem.

Comment hidden because of low score. Click to expand.
0

both numbers of the pair must lie within the range [A,B] that are given as input.

Comment hidden because of low score. Click to expand.
0

So both numbers of the "pair" (134, 413, 341)?

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````#include "bits/stdc++.h"
#define FOR(i, a, n) for(int i = a; i < n; i++)
#define ft first
#define sd second
#define so(x) cout<<(x)<<"\n";
#define si(x) cin>>x;
#define ll long long
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
#define mod 1000000007
using namespace std;

int main() {
int a, b;
cin>>a>>b;
bool marked[b+1];
for(int i = 0; i <= b; i++)
marked[i] = false;
string s = "", s1 = "";
ll res = 0;
int count = 0;
for(int i = a; i <= b; i++) {
if(marked[i])
continue;
marked[i] = true;
stringstream ss;
ss << i;
s = ss.str();
s1 = s+s;
int size = s.length();
count = 1;
for(int j = 1; j < size; j++) {
string s2 = s1.substr(j, size);
int x = atoi(s2.c_str());
if(x >= a && x <= b && !marked[x]){
count++;
marked[x] = true;
}
}
res += (count*(count-1))/2;
}
cout<<res<<"\n";
}``````

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.