Intern Interview Questions in San Jose, CA | Glassdoor # Intern Interview Questions in San Jose, CA

From retail to finance to medicine, every industry needs interns to provide additional support and assistance. Interview questions will vary greatly depending on the industry and role you are looking for. Expect to answer questions about how you work on teams and provide examples of any relevant work experience. To ace your interview, make sure to research the particular position you are applying for.

## Top Interview Questions

Sort: RelevancePopular Date

Feb 25, 2012

Mar 30, 2010

Dec 30, 2011
 Find occurrences of a number in sorted array (allow duplicates).8 AnswersO(logN) requiredUse binary search to find the number (O(logN)). Once that is done you can search around that index. Though that could become O(N). Better answer: run binary search again twice once you have found the number the first time. For the upper half and the lower half - so total run time is O(logN)I think it is not possible in O(logN) because anyway traversing the complete array is needed to access all the numbers. Worst Case scenario would be the last number repeating itself 5 times. For example : {1,2,2,3,3,3,4,4,4,4,5,5,5,5,5} and if you are asked to find out the occurrences of number '5' then you have to traverse the complete array once which means the complexity should be O(N).Show More ResponsesJAVA Code : // For Sorted and UnSorted Array in O(N) time Complexity. import java.util.HashMap; public class FindOccurrences { /** * @param args */ public static void main(String[] args) { int unsortedArray[] = {4,6,7,8,4,5,6,8,3,2,4,5,7,8,9,3,4,6,7,8}; System.out.println(findOccurrencesUnsorted(unsortedArray,8)); int sortedArray[] = {1,2,2,3,3,3,4,4,4,4,5,5,5,5,5}; System.out.println(findOccurrencesSorted(sortedArray,5)); } private static int findOccurrencesUnsorted(int[] array, int number) { HashMap map = new HashMap(); for(int i=0;iO(logN) is possible for sorted arrays, the key here is to firstly check beginning and end to determine next binary-search steps, I attached my code below, and I think this is O(logN) in worst case. //inputs are the sorted array, k is the number looking for //start and end are two index values, main method calls with (start=0) and (end=length-1) int GetOccurance(int[] inputs, int k, int start, int end) { if(startk) return 0; if(inputs[start]==k&&inputs[end]==k) return end-start+1; int mid = (start+end)/2; if(input[mid]k) return GetOccurance(inputs, k, start, mid-1); else return GetOccurance(inputs, k, start, mid-1)+1+GetOccurance(inputs, k, mid+1, end); }With the last algorithm, how does it ever return anything but 0? If main calls with start := 0 and end := length - 1? The only case where you get past the base case is if the array is length 1... since (start < end) = (0 < length -1) from the input... and returns 0...Also, I think there is a good shot at a stack overflow with this method. I would add an extra variable and solve the problem tail recursively.Try this. int findLeftEdge( int A[], int num, int val ){ int mid = num/2; if( num == 1 ){ return 0; }else{ if( A[mid] == val && A[mid-1] != val ){ return mid; }else if( A[mid] == val || A[mid] > val ){ return findLeftEdge( A, mid, val ); }else if( A[mid] val ){ return findRightEdge( A, mid, val ); } } } int countOccurrenceSortedArray( int A[], int num, int val ){ int left = findLeftEdge( A, num, val ); int right = findRightEdge( A, num, val ); return right-left+1; } int main() { // your code goes here int A[] = { 1, 5, 10, 10, 12, 19, 19, 19, 20, 20}; int ans = countOccurrenceSortedArray( A, sizeof(A)/sizeof(int), 20 ); cout << ans << endl; return 0; }

Oct 14, 2011

Jan 19, 2011

### Software Engineer Intern at PayPal was asked...

Apr 25, 2012
 n= 20 for (i=0;i

Sep 21, 2011
 Generate a new array from an array of numbers. Start from the beginning. Put the number of some number first, and then that number. For example, from array 1, 1, 2, 3, 3, 1 You should get 2, 1, 1, 2, 2, 3, 1, 1 Write a program to solve this problem.7 Answersint[] Reformat(int[] original, int length) { LinkedList list = new LinkedList(); int currentCount; for(int i=0;ifunction numberArray( \$arr ){ \$a = array(); \$number = null; \$c = -1; foreach( \$arr as \$v ){ if( \$v != \$number ){ if( \$number ){ \$a[] = \$c; \$a[] = \$number; } \$number = \$v; \$c = 1; } else { ++\$c; } } if( \$c > 0 ){ \$a[] = \$c; \$a[] = \$number; } return \$a; } var_export( numberArray( array( 1,1,2,3,3,1 ) ) );\$val) { echo \$val . "\t"; } echo " \n"; } ?>Show More Responsesworking in php: sizeof(\$list)-2) || (\$list[\$i]!=\$list[\$i+1])){ \$result[]=\$count; for(\$j=0;\$jvector reformat(int arr[], int size) { vector res; int j, count = 0; for(int i = 0; i < size; ) { cout << i << endl; count = 0; for(j = i; j < size; j++) { if(arr[j] != arr[i]) break; count++; } res.push_back(count); res.push_back(arr[i]); i = j; } return res; }int i=0; int j=1; ArrayList array=new ArrayList(); while(i@Anonymous: Your inner while loop will cause an out-of-bounds exception to be thrown when your scanning hits the end of the array. Your while loop will try to access givenArr[i+j] even when j increments to the point that surpasses the length of the array. You need while((i+j) != givenArr.length ... )

Mar 6, 2011
 Write a function that finds the minimum and maximum values within an unsorted array using divide-and-conquer.6 AnswersThe best I can do in Java: int findMinimum(int[] a, int start, int end){ if (end-start == 0){ return a[end]; } if (end-start == 1){ if (a[end] = 2){ int split = (start+end)/2; int leftLeast = findMinimum(a, start, split); int rightLeast = findMinimum(a, split+1, end); if (leftLeastvoid GetMinMax(int[] array, out int minValue, out int maxValue) { if (array == null || array.Length == 0) throw new ArgumentException("array null or empty."); MinMax minmax = GetMinMax(array, 0, array.Length - 1); minValue = minmax.Min; maxValue = minmax.Max; } MinMax GetMinMax(int[] array, int begin, int end) { if (begin == end) return new MinMax { Min = array[begin], Max = array[begin] }; else if (begin + 1 == end) return new MinMax { Min = Math.Min(array[begin], array[end]), Max = Math.Max(array[begin], array[end]) }; else { int mid = begin + (end - begin) / 2; MinMax left = GetMinMax(array, begin, mid); MinMax right = GetMinMax(array, mid + 1, end); return new MinMax { Min = Math.Min(left.Min, right.Min), Max = Math.Max(left.Max, right.Max) }; } } struct MinMax { public int Min; public int Max; }#include #include void devide_conque(int*, int, int, int*, int*); int main(int argc, char** argv) { int min, max; int i = 0, array_size = (argc - 1); int* array = (int*) malloc(sizeof(int) * (argc - 1)); for (; i rmax ? lmax : rmax; } }Show More Responsespublic static int[] minMax(int[] a) { int[] mm = new int; if (a.length > 0) { mm = a; mm = a; } mm = minMax(a,0,a.length-1); return mm; } public static int[] minMax(int[] a, int low, int high) { int[] temp = new int; if (low+1 < high) { int mid = (low+high)/2; int[] temp1 = minMax(a,low,mid); int[] temp2 = minMax(a,mid+1,high); temp = Math.min(temp1,temp2); temp = Math.max(temp1,temp2); return temp; } else if (low <= high) { if (a[low] < a[high]) { temp = a[low]; temp = a[high]; } else { temp = a[high]; temp = a[low]; } } return temp; }def find_min_max(arr): return min_max(arr, 0, len(arr)-1, 1e308,-1e308) def min_max(arr, i, j, mn, mx): if not arr or i > j: return mn, mx elif i == j: return min(mn, arr[i]), max(mx,arr[i]) else: mid = ( i + j) / 2 left = min_max(arr, i, mid-1, min(mn, arr[mid]), min(mn, arr[mid])) right = min_max(arr, mid+1, j, min(mn, arr[mid]), max(mx,arr[mid])) return min(left, right), max(left, right)first divide list in two, compare number from each list so we got 1list where the minimum is and second list where maximun is. Search for the min in the first list and the max in the second list. \$list[\$n-1-\$i]){ \$temp = \$list[\$i]; \$list[\$i] = \$list[\$n-1-\$i]; \$list[\$n-1-\$i] = \$temp; } } \$min = \$list; for(\$i=1;\$i\$max) \$max=\$list[\$i]; } \$result = array('min'=>\$min, 'max'=>\$max); return \$result; } ?>

### Software Engineering Intern at Palantir Technologies was asked...

Apr 16, 2012
 Say you have a single-column table of entries of variable size. Implement this table to also contain methods to lengthen one cell, cut a cell shorter, and to return which cell we're pointing at if given a certain distance from the beginning of the table. All methods need to be fast (assume a single-column table with many many entries).6 AnswersOne way to do this is to use the doubly linked list. Assuming lengthening and cutting short a cell happens only at the end of the table, then both operations can be done easily and quickly on a D.L.List. Not sure what the interviewer meant by distance from beginning of the table... like number of bytes from the beginning of the table and he wants the cell number?For example, if each cell has length 5, and the user clicks on 13 from the top, then you need to let the user know he has clicked on cell 3. This operation needs to be fast.The search function needs to be doable in less than linear time, and so do inserts and deletesShow More Responsesbinary indexed treeslink list of link listsAn dynamically allocated array that can be resized..