Eatclub Interview Question for Consultants


Country: United States




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

static void ReGroup(List<int> Numbers)
        {
            int groupCount = 0;
            int groups = Numbers.Count / 3;
            for (int i = 0; i != groups; i++)
            {
                int secOne = Numbers[groupCount];
                groupCount++;
                int secTwo = Numbers[groupCount];
                groupCount++;
                int secTree = Numbers[groupCount];
                groupCount++;
                

                int currnet = groupCount - 1;
                Console.WriteLine(currnet);

                Numbers[currnet] = secOne;
                currnet--;
                Numbers[currnet] = secTwo;
                currnet--;
                Numbers[currnet] = secTree;

            }

        }

- ItsOnlyJenn December 13, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void reverseArrSect(int iArr[n],int iSec)
{
	int iTemp = -1;
	cout << endl << "reverse sections of array";
	for(int i=0;i<n;i+=iSec)
	{
		iTemp =  iArr[i];
		iArr[i] = iArr[i+2];
		iArr[i+2] = iTemp;
		cout << iArr[i] <<','<< iArr[i+1] << ','<<iArr[i+2] << ',';
	}
}

- sv December 14, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

the solutions does not handle the situation when last section is not full, i.e. contains 1 or 2 elements.

- zr.roman December 20, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Very easy program. Written in c#

private static void ReverseArray() {
			// in C#, given a list of numbers [4,8,20,11,12,18,50,10,11] and divided in sections of 3
			// Reverse each section without using another array
			int[] array = { 4,8,20,11,12,18,50,10,11 };
			
			Console.WriteLine("Original array");
			for(int i=0;i<array.Length;i++) {
				Console.Write("{0} ", array[i]);
			}
			
			// Traverse the array stepping by 3
			for (int i=0; i<array.Length; i+=3) {
				// Just I need to swap first and third
				int temp = array[i];
				array[i] = array[i+2];
				array[i+2] = temp;
			}
			
			Console.WriteLine("Reversed");
			for(int i=0;i<array.Length;i++) {
				Console.Write("{0} ", array[i]);
			}
			
		}

- maximilianorios December 22, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

if the array length is even then exception will occur

- Anonymous December 22, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

if the array length is even, then exception will occur

- marx December 22, 2015 | Flag


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