0% found this document useful (0 votes)
9 views2 pages

wissenTechInterview 20thdec2023

The document contains two Java programs. The first program aims to split an array into smaller arrays of a specified size, but the implementation is incomplete. The second program is intended to flatten a nested array structure into a single-dimensional array, but it also lacks a complete implementation.

Uploaded by

leena swarnaker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

wissenTechInterview 20thdec2023

The document contains two Java programs. The first program aims to split an array into smaller arrays of a specified size, but the implementation is incomplete. The second program is intended to flatten a nested array structure into a single-dimensional array, but it also lacks a complete implementation.

Uploaded by

leena swarnaker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

/******************************************************************************

Welcome to GDB Online.


Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
import java.util.*;

class Main
{
public static void main(String[] args) {
int[] original = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int splitSize = 3;

/* expected Output
[0, 1, 2]
[3, 4, 5]
[6, 7, 8]
[9]
*/

List<int[]> list = splitArray(original, splitSize);


list.forEach(splitArray ->
System.out.println(Arrays.toString(splitArray)));
}

public static List<int[]> splitArray(int[] c, int splitSize)


{
List<int[]> splitList=new ArrayList<int[]>();
int t=0;
List<int> tempList;
for(int i=0;i<c.length;i++ )
{
if(t>splitSize )
{
tempList=new ArrayList<int>();
}
}
}
}
===================================================================================
=====================
/******************************************************************************
Welcome to GDB Online.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
public class Main
{
public static void main(String[] args) throws Exception{
Object[] array = { 1, 2, new Object[]{ 3, 4, new Object[]{ 5 }, 6, 7 },
8, 9, 10 };

// Example Input -> [[[1],2],[3,4]] Output -> [1,2,3,4]

Integer[] flattenedArray = flatten(array);

System.out.println(Arrays.toString(flattenedArray));
}

public static Integer[] flatten(Object[] inputArray) throws Exception {


}

You might also like