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.

- Dave September 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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

- ritwik_pandey September 01, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

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

- Dave September 01, 2015 | Flag
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";
}

- Himanshu Garg September 18, 2016 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More