Interview Question for Software Engineer Interns

Country: United States
Interview Type: In-Person

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

static List<ArrayList> GetAllArray(int[] intData)
            List<ArrayList> AllArray = new List<ArrayList>();

            //Create 20 Array in array collection
            for (int i = 0; i < 20; i++)
                AllArray.Add(new ArrayList());

            //Read each data
            for (int i = 0; i < intData.Length; i++ )
                AllArray[i % 20].Add(intData[i]);

            return AllArray;

In this solution provide O(n) solution

- Rajesh Kumar August 29, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

Simple solution for this problem in php
Complexty : O(N*N)

function getAllTwentiethElements ($inputArray) {
    $arraySize = count($inputArray);
    $outputArrayCollection = array();
    if ($arraySize <= 20) {
      return $outputArrayCollection;
    for ($i = 0; $i < $arraySize; $i++) { 
         $outputArray = array();
         for ($j = $i; $j < $arraySize; ($j = $j+20)) {
            $outputArray [] = $inputArray[$j];
        $outputArrayCollection[] = $outputArray;
    return $outputArrayCollection;
$inputArray  = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23);
$outputArrayCollection = getAllTwentiethElements($inputArray);

- Praveen Pandey August 29, 2014 | Flag Reply

Add a Comment

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


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


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