Oracle Interview Question for Senior Software Development Engineers


Country: India
Interview Type: In-Person




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

for(int i=0; i<array_length; i++)
	{
		for (int j= i+1; j<array_length; j++)
		{
			if (array[i]==array[j])
			{
				// match found
				return;
			}
		}
	}

- Anupom Chakrabarty July 05, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

class Main{
static void printFirstRepeating(int arr[]) {
int min = -1;
HashSet<Integer> set = new HashSet<>();
for (int i=arr.length-1; i>=0; i--) {
if (set.contains(arr[i]))
min = i;
else
set.add(arr[i]);
}
if (min != -1)
System.out.println("The first repeating element is " + arr[min]);
else
System.out.println("There are no repeating elements");
}
public static void main (String[] args) throws java.lang.Exception {
int arr[] = {10, 5, 3, 4, 3, 5, 6};
printFirstRepeating(arr);
}
}

- Anonymous August 17, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

private static void FindFirstDuplicate(int[] arr)
{
List<int> previousItems = new List<int>();
for (int i = 0; i < arr.Length; i++)
{
if (previousItems.Contains(arr[i]))
{
Console.WriteLine("First Duplicate Occurence is {0}", arr[i]);
return;
}
previousItems.Add(arr[i]);
}
}

- sathish July 13, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Map;
import java.util.HashMap;
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int[] intArray = {5, 4, 6, 8, 9};
		Map<Integer, Integer> freqCountMap = new HashMap<Integer, Integer>();
		for(int a : intArray) {
			Integer k = freqCountMap.get(a);
			if(k != null) {
				System.out.println("First duplicate occurrence is for " + a);
				break;
			}
			else {
				freqCountMap.put(a, 1);
			}
		}
	}
}

- Anonymous July 27, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Map;
import java.util.HashMap;
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int[] intArray = {5, 4, 6, 8, 9};
		Map<Integer, Integer> freqCountMap = new HashMap<Integer, Integer>();
		for(int a : intArray) {
			Integer k = freqCountMap.get(a);
			if(k != null) {
				System.out.println("First duplicate occurrence is for " + a);
				break;
			}
			else {
				freqCountMap.put(a, 1);
			}
		}
	}
}

- Anonymous July 27, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Map;
import java.util.HashMap;
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int[] intArray = {5, 4, 6, 8, 9};
		Map<Integer, Integer> freqCountMap = new HashMap<Integer, Integer>();
		for(int a : intArray) {
			Integer k = freqCountMap.get(a);
			if(k != null) {
				System.out.println("First duplicate occurrence is for " + a);
				break;
			}
			else {
				freqCountMap.put(a, 1);
			}
		}
	}
}

- GodOfWar4 July 27, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class Main{
static void printFirstRepeating(int arr[]) {
int min = -1;
HashSet<Integer> set = new HashSet<>();
for (int i=arr.length-1; i>=0; i--) {
if (set.contains(arr[i]))
min = i;
else
set.add(arr[i]);
}
if (min != -1)
System.out.println("The first repeating element is " + arr[min]);
else
System.out.println("There are no repeating elements");
}
public static void main (String[] args) throws java.lang.Exception {
int arr[] = {10, 5, 3, 4, 3, 5, 6};
printFirstRepeating(arr);
}
}

- preety July 28, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class MyCode {
  public static void main (String[] args) {
        
      int[] numbers = {3,4,6,7,2,4,8,3,3,0};
      HashSet<Integer> viewed = new HashSet<>();
      
      int index = -1;

      for(int i=0; i < numbers.length; i++) {
        if(viewed.contains(numbers[i])) {
            index = i;
            break;
          }else {
            viewed.add(numbers[i]);  
          }
      }             
    System.out.printf("index = %d, value=%d", index, numbers[index]);
  }
}

- GSS August 31, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

int* first_dup(int *val,int value)
{
int b,a=5;
int *start=val;

while(a)
{
if (*val==value)
{
b=(val-start)+1;
val++;
while(b!=5)
{
if (*val==value)
return val;
else
b++;
val++;
}
}
else
val++;
a--;
}
printf("No matching value");
return NULL;
}

main()
{
int array[5],b,a=0;
while(a!=5)
{
printf("Enter the five values:");
scanf("%d",&b);
array[a]=b;
a++;
}
printf("Enter the value what to check the duplicate:");
scanf("%d",&b);
int *pos=first_dup(array,b);
b=(pos-array);
printf("the pos is : %d ",b);
}

- Anonymous January 28, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

int* first_dup(int *val,int value)
{
int b,a=5;
int *start=val;

while(a)
{
if (*val==value)
{
b=(val-start)+1;
val++;
while(b!=5)
{
if (*val==value)
return val;
else
b++;
val++;
}
}
else
val++;
a--;
}
printf("No matching value");
return NULL;
}

main()
{
int array[5],b,a=0;
while(a!=5)
{
printf("Enter the five values:");
scanf("%d",&b);
array[a]=b;
a++;
}
printf("Enter the value what to check the duplicate:");
scanf("%d",&b);
int *pos=first_dup(array,b);
b=(pos-array);
printf("the pos is : %d ",b);
}

- Anonymous January 28, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

int* first_dup(int *val,int value)
{
int b,a=5;
int *start=val;

while(a)
{
if (*val==value)
{
b=(val-start)+1;
val++;
while(b!=5)
{
if (*val==value)
return val;
else
b++;
val++;
}
}
else
val++;
a--;
}
printf("No matching value");
return NULL;
}

main()
{
int array[5],b,a=0;
while(a!=5)
{
printf("Enter the five values:");
scanf("%d",&b);
array[a]=b;
a++;
}
printf("Enter the value what to check the duplicate:");
scanf("%d",&b);
int *pos=first_dup(array,b);
b=(pos-array);
printf("the pos is : %d ",b);
}

- Rupam January 28, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Set;
import java.util.HashSet;
class FindFirstDuplicateOccurence{
	public static int findFirstDuplicate(int[] arr){
		Set<Integer> visited = new HashSet<>();
		for(int i=0;i<arr.length;++i){
			if(visited.contains(arr[i]))
				return i;
			else
				visited.add(arr[i]);
		}
		return -1;
	}

	public static void main(String[] args) {
		// int[] arr = {7, 5, 3, 5, 7, 3, 7, 5};
		int[] arr = {1, 2, 3};
		int i = findFirstDuplicate(arr);
		if(-1==i)
			System.out.println("no duplicates");
		else
			System.out.println("first duplicate value = "+arr[i]);
	}

}

- Simon March 24, 2019 | 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