Cisco Systems Interview Question for SDE-2s


Country: United States
Interview Type: In-Person




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

How is the result computed? Does an element needs to pass all of the filters or any one of them?

- Balajiganapathi S August 14, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Result needs to be passed as an list of all the filters. In best case, one filter would cover all elements. Otherwise, we need to get the optimum number of filters to do the same.

- vaibhavrastogi4 August 14, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I'm not too sure I understood what the question was completely but here is the code that I wrote:

public class testint {

	public static void main(String[] args) {
        String[] test = args;
        
        function("1xxx","1000",test);
        //System.out.println(args);
    }

    public static void function(String ID, String mask,String[] str)
    {
    	char[] idnotx = new char[ID.length()];
    	char[] masknot0 = new char [mask.length()];
    	char idval = 'x';
    	char maskval = 'x';
    	idnotx = ID.toCharArray();
    	masknot0=mask.toCharArray();
    	int pos = -1;
    	int pos0 = -1;
    	for(int i = 0;i<ID.length(); i++)
    	{
    		if(idnotx[i] != 'x')
    		{
    			pos = i;
    			idval = idnotx[i];
    		}
    	}
    	
    	for(int i=0;i<mask.length();i++)
    	{
    		if(masknot0[i] != '0')
    		{
    			pos0 = i;
    			maskval = masknot0[i];
    		}
    	}
    	
    	for(int i = 0; i<str.length; i++)
    	{
    		char[] temp = new char[str[i].length()];
    		temp = str[i].toCharArray();
    		if(temp[pos0] == idval)
    			System.out.println(str[i]);
    	}
    	//System.out.println(pos);
    	//System.out.println(pos0);
    	//System.out.println(idval);
    	//System.out.println(maskval);
    	//System.out.println(str.length);
    	
    }

}

Here are the results:

C:\Users\Admin\Desktop>javac testint.java

C:\Users\Admin\Desktop>java testint 1001 0101 1100 0011 1111 0000 0001

1001
1100
1111

- Ron March 06, 2015 | Flag Reply


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