Accenture Interview Question for Front-end Software Engineers


Country: Australia
Interview Type: In-Person




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

sum = 0

{
For ( i = 0 ; i < rowsize ;i++ )

{
if ( i == (rowsize -1 - i ))
{
sum = sum + a[i][i]
}
else{
sum = sum + a[i][i] + a[rowsize -1 - i][rowsize -1 - i]
}
}


}

- selva September 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

selva if u knw ths ques & ans very well ,u can post the answer with full explanation..or any site..

- Anonymous September 13, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This means u need to exclude the intersecting element of two diagonals

- Dinesh Pant September 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Huh? Are you sure that's all? It's easy (assume 0 indexed):
{{
for(i=0; i<n/2; i++)
sum+= A[i][i] + A[i][n-i] + A[n-i][i] + A[n][n];

return ( sum + A[(n+1)/2][(n+1)/2] );
}}

For meaning of this code, sit down and work it through (it's only 2 lines really)

- bigphatkdawg September 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

for(i=0; i<n/2; i++) {
	sum+= A[i][i] + A[i][n-i] + A[n-i][i] + A[n][n];
}
return ( sum + A[(n+1)/2][(n+1)/2] );

Corrected formatting.

- bigphatkdawg September 18, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

for(i=0; i<n/2; i++) {
	sum+= A[i][i] + A[i][n-i] + A[n-i][i] + A[n-i][n-i];
}
return ( sum + A[(n+1)/2][(n+1)/2] );

- bigphatkdawg September 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

JavaScript

(function(){

  var a = [
    [3, 5, 9, 2, 6],
    [7, 9, 2, 1, 2],
    [4, 7, 2, 0, 9],
    [6, 8, 3, 5, 6],
    [1, 1, 2, 3, 4]
  ];

  alert(getSum(a));

})();

function getSum(a){

  // the diagonal elements of the array are:
  //
  // [x       x]
  // [  x   x  ]
  // [    +    ]
  // [  x   x  ]
  // [x       x]
  //
  // with the intersecting element marked with +

  // so, you need to add the elements at these locations:
  //
  //  \ diagonal: [0,0] [1,1] [2,2] [3,3] [4,4]
  //  / diagonal: [0,4] [1,3] [2,2] [3,1] [4,0]
  //
  // but only add the [2,2] element once
  //
  // this can be accomplished with a single loop through the array, i.e.
  //
  // [0,0] + [0,4] + [1,1] + [1,3] + [2,2] + [3,3] + [3,1] + [4,4] + [4,0]

  var i, j, n = a.length, sum = 0;

  for(i=0;i<n;i++) {
    j = n - i - 1;
    sum += a[i][i] + ( i == j ? 0 : a[i][j] );
  }

  return sum;

}

- ic3b3rg November 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Give xplanation

- Anonymous April 25, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

sum = 0;

for (i=1; i<=n ; i++ )
{
if( 2i == n+1)
{
sum = sum + array[i,i]
}
else
{
sum = sum + array[i,i] + array [i,n-i+1]
}
}

- Dinesh September 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

k any meaning of this code? pls explain@@

- Anonymous September 13, 2013 | 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