EFI Interview Question for Software Engineers

Country: India
Interview Type: In-Person

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

In ZoomBA, or rather any other language, the logic should be clear like this :

// get file iterator - line by line 
fi1 = file('large1.txt')
fi2 = file('large2.txt')
fo = open('merged' ,'w')
// when both are non empty - interleave 
while ( fi1.hasNext && fi2.hasNext  ){
  fo.println( fi1.next )
  fo.println( fi2.next )  
// when one is leftover, find it and drop lines 
if ( fi1.hasNext || fi2.hasNext ){
  leftover = fi1.hasNext ? fi1 : fi2 
  while ( leftover.hasNext ){
    fo.println( leftover.next )  
// do not forget to close 

- NoOne December 20, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
of 1 vote

package com.practice;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.io.Writer;

public class InterleaveLines {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String fileName1 = "src/com/practice/fileName1";
		String fileName2 = "src/com/practice/fileName2";
		interleaveLines(fileName1, fileName2);
	public static void interleaveLines(String fileName1, String fileName2) {
		BufferedWriter writer = null;
		System.out.println(new File(".").getAbsoluteFile());
		try {
			File newFile = new File("src/com/practice/interleave");
			writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile)));
			BufferedReader reader1 = new BufferedReader(new FileReader(fileName1));
			BufferedReader reader2 = new BufferedReader(new FileReader(fileName2));
			String line1 = reader1.readLine(); 
			String line2 = reader2.readLine();
			while (line1 != null && line2 != null) {
				line1 = reader1.readLine();
				line2 = reader2.readLine();
			if (line1 != null || line2 != null) {
				BufferedReader reader = line1 != null ? reader1 : reader2;
				String line = line1 != null? line1: line2;
				while (line != null) {
					line = reader.readLine();
		catch(Exception e) {
		finally {
			try {
			catch (Exception ex) {


- Anonymous December 20, 2016 | 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