Concur Interview Question for Technical Architects


Country: India
Interview Type: In-Person




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

Here you go

This will give you the first index of such occurrence

public static int FirstOccurrence(string inputString)
{
	if(String.IsNullOrWhiteSpace(inputString)
	{
		throw new ArgumentException()
	}
	int j = 0;
	boolean foundFirstDigitOccurrence = true;
	for(int i = 0 ; i < inputString.Length;i++)
	{
		j = i;
		foundFirstDigitOccurrence = true;
		while(j < inputString.Length && inputString[j] != '.')
		{
			if(inputString[j] < 48 && inputString[j] > 57)
			{
				foundFirstDigitOccurrence = false;
			}
			j++;
		}
		if(foundFirstDigitOccurrence && j != i)
		{
			return i;
		}
		i = j;
	}
}

This will give you the index of first such digits. You can always print it from i to j.
The complexity is O(N) + O(1) here.

- sonesh March 30, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you explain how the complexity if O(N) + O(1) it looks like O(N2)

- ujjdav27 August 24, 2017 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you explain how complexity is O(N) + O(1)

- ujjdav27 August 24, 2017 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

how is complexity O(N) + O(1) can you please explain...it looks like O(N2) to me

- ujj.dav27 August 24, 2017 | 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