Sonoa Systems Interview Question for Testing / Quality Assurances






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

Use Hashtable

- Anonymous June 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think we can sort the array and remove the duplicates like...

sort(a);
l=a.length();
j=0;
for(i=0;i<l;i++)
{
if(a[j]!=a[i])



}

- RajiniHassan January 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think we can sort the array and remove the duplicates like...

sort(a);
l=a.length();
j=0;
for(i=0;i<l;i++)
{
if(a[j]!=a[i])
{
j++;
a[j]=a[i];
}
}
so by this way we need o(nlogn) to sort the array and again a o(n2) to remove duplicates...

- RajiniHassan January 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

the other possibilities can be like...
i=0;
while(i<a.length)
{
if( !contain(a[i]) )
{
m[r]=a[i];r++;
}
i++;
}


int contain(int n)
{
int j;
for(j=0;j<r;j++)
{
if(m[j]==n)
return 1;
}
return 0;
}

- RajiniHassan January 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sorting takes o(nlogn) time you can use hashtable

1. start from array check if number is already present in hashtable or not if no put inplace in array
2.if yes check next element..
so o(n) time and o(1) space

- ridercoder October 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In python...

def duplicate(lst):
    lst1 = []
    l = len(lst)
    i = 0
    while i < l:
        if lst[i] not in lst1:
            lst1.append(lst[i])
        i += 1
    return lst1

- python January 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace RemoveDupsinArray
{
    class Program
    {
        
        static void Main(string[] args)
        {
            int[] array = { -4, 0, 1, 6, 0, 1, 6, -2 };
            RemoveDups(array);
            Console.Read();
        }
        public static void RemoveDups(int[] array)
        {
            Hashtable ht = new Hashtable();
            string output = "";
            for (int i = 0; i < array.Length; i++)
            {
                if (!ht.ContainsKey(array[i]))
                {
                    ht.Add(array[i],0);
                    output += " " + array[i]; 
                }
                
            }
            Console.WriteLine("{0} ", output);
            
        }
    }
}
output: -4 0 1 6 -2

- Viji January 14, 2013 | 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