Software Engineering Interview Questions in San Jose, CA | Glassdoor

# Software Engineering Interview Questions in San Jose, CA

1,545

Software engineering interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

Dec 16, 2010

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

Jan 19, 2011
 Questions related to data structures like "What data structure would you use for a browser's BACK & FORWARD ability"6 AnswersMay be Stack , any one please correct me if I am wrong.This can be implemented by using two different stacks, one for back and one for forward.Command PatternShow More ResponsesI would use doubly link listDoubly linkedListUse two stacks. Every time you visit a site, push its address in stack1. When you press back, pop from stack1 and also push in stack2. When user presses forward, pop from stack2 and also push in stack1.

Oct 1, 2010
 Given a matrix print it clockwise from the first element to the very inner element.6 AnswersNeed to design the program first and then implement it very carefully yet fast!void PrintMatrix(int** a, int n) { for (int i = 0; i = i; j--) { printf("%d ", a[n - i -1][j]); } } void PrintColInc(int** a, int n, int i) { for (int j = i; j = i; j--) { printf("%d ", a[j][i]); } }struct point { point(int a, int b) { row = a; col = b; } int row; int col; }; void printMatrixSpiral(int a[][5], int r, int c) { int direction = 1; // 1 - right // 2 - down // 3 - left // 4 - up point upper_left = point(0,0); //point upper_right = point(0,c-1); point lower_right = point(r-1, c-1); //point lower_bottom = point(r-1, 0); while(true){ if(direction==1){ int row = upper_left.row; for(int i=upper_left.col; i= upper_left.col;--i){ cout= upper_left.row;--i){ cout lower_right.row) || (upper_left.col > lower_right.col)){break;} } }Show More Responsesint matrix[][3] = { {1, 2, 3}, { 4, 5, 6}, {7, 8, 9} }; void PrintMatrix() { int start = 0; int end = 2; while(end >= start) { for(int col = start; col = start; col--) cout start; row--) cout << matrix[row][start] << " "; start++; end--; } }int main() { int m, n; cin >> m >> n; int matrix[m][n]; for (int i = 0; i > matrix[i][j]; int l = 0, r = n, t = 0, b = m; while (l = l; i--) cout = t; i--) cout << matrix[i][l] << ' '; l++; } return 0; }^ Above anon, your solution is almost correct. But for the 3rd and 4th for loops you first need to check whether you've already printed the corresponding previous for loop. Ok I didn't explain that too clearly. Here's an example: Matrix: {{1,2,3,4},{5,6,7,8},{9,10,11,12}} will print 1 2 3 4 8 12 11 10 9 5 6 7 6 That last 6 is because of the 3rd for-loop. You don't need to run that opposite for-loop (R-L) once you've already printed 6 from L-R. Just use an if-loop to rectify this. Same for the 4th loop.

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

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

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

Dec 18, 2011
 CODING (weight: 50%) The string "PAYPAL IS HIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: PAHNAPLSIIGYIR Write the code that will take a string and make this conversion given a number of rows: String convert(String text, int nRows); convert("paypalishiring", 3) should return "pahnaplsiigyir" 6 Answersstatic String convert(String sentence, int numberOfRows) { char[] arr = sentence.toCharArray(); String ret = ""; if(numberOfRows == 1) return sentence; int repeatPattern = numberOfRows + (numberOfRows - 2); for(int i = 0; i < numberOfRows; i++){ int s = i; do{ ret += String.valueOf(arr[s]); if(i < numberOfRows - 1 ) { s = s + repeatPattern; } else s = s + numberOfRows + (numberOfRows - 2); }while(s < arr.length); repeatPattern -= 2; } return ret; }void convert(String s,int r){ int len=s.length(); ArrayList> allLine=new ArrayList>(); for(int i=0;i line=new ArrayList(); allLine.add(line);} int row=0,i=0; while(i0 && istatic String convert_al(String text, int nRows) { char [] char_array = text.toCharArray(); StringBuffer []array = new StringBuffer[nRows]; for(int i=0;i0 && iShow More Responsespublic static StringBuilder strConversion(String in,int rows) { StringBuilder[] stb=new StringBuilder[rows]; StringBuilder out=new StringBuilder(); int index=0; int i=0; for(int j=0;jstring convert(const string& input, int rowCount) { if ((input.length() == 0) || (rowCount > arrStrings; arrStrings.resize(rowCount); vector &currArray = arrStrings[0]; currArray.push_back(input.substr(0, 1)); for (int idx = 1; idx &currArray = arrStrings[rowIdx]; currArray.push_back(input.substr(idx, 1)); } for (int rowIdx = rowCount - 2; rowIdx >= 0 && idx &currArray = arrStrings[rowIdx]; currArray.push_back(input.substr(idx, 1)); } } string strTemp; for (size_t idx = 0; idx &currArray = arrStrings[idx]; for (size_t j = 0; j < currArray.size(); j++) { cout << currArray[j] << " "; strTemp += currArray[j]; } cout << endl; } return strTemp; }package com.learn; public class ZIGZAGPattern { public static void main(String[] args) { ZIGZAGPattern pattern = new ZIGZAGPattern(); System.out.println(pattern.strConvertToZigZag("PAYPALISHIRING",3)); } public String strConvertToZigZag(String str, int rows) { StringBuffer []sb = new StringBuffer[rows]; StringBuffer finalsb = new StringBuffer(); for(int i=0;i0 && count

Jan 2, 2014

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

Nov 10, 2011
 Consider the following function: int f (int num) { int out = 0; for (; num > 0; num /= 10) { int d = num % 10; out *= 10; out += d; } return out; } 1) What does it do? 2) Write the same algorithm using recursion5 AnswersThere is a trick that need global variable or static variable to record the temper sum. so the function declaration cannot be same as loop version if don't use global or static variable. the output parameter b will be the reverse result. void rev(int d, int& b) { b *= 10; if (d/10 == 0) b += d; else { b += d%10; rev(d/10, b); } }You can do it without the golbal or static variables: int f(int num) { if((num/10) == 0) return num; else return ( 10(num%10) + f(num/10) ); }Sorry my answer previously posted was wrong. Here is the correct one without golbal or static variables, which is basically the same as the first one by Paul. inf f(int num, int car=0) { car *=10; if((num/10) == 0) return ( car + num ); else return f(num/10, car+(num%10) ); }Show More Responsesprivate static int reverse(int n, int r) { if (n == 0) return r; return reverse(n/10, 10*r+n%10); } public static int reverse(int n) { return reverse(n, 0); }Simple method without using global variable. static int reverseRecursive(int number, int sum) { if (number != 0) { int temp = number % 10; sum = sum * 10 + temp; return reverseRecursive((number / 10), sum); } else return sum; }

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

May 17, 2012
 Assuming a preexisting list of 100 words, how would you efficiently see if a word received from input is an anagram of any of the 100 words?4 AnswersFirst Sort 100 words and keep the hash of sorted words.. Now when you recieve a word, SOrt it and check if Hash contains that key. O(nlogn) Where n is length of String.Hi I think you can take a look at the most efficient algorithm for this question in this link www.crackeasily.com/2012/01/find-whether-2-strings-are-anagrams.htmlTo say what MW said more clearly: If you sort words that are the same anagram they will always look the same. Example: "god" and "dog" both look like "dgo". So you sort the input word, then you iterate through the list of 100 words, and while looking at each word sort that word. compare if the input and that word are the same. If they are then you have found an anagram. if you made it to the end of the list and you haven't found an anagram then an anagram does not exist in the list.Show More ResponsesSorting takes O(nLogn) average time. This can be further improved by counting characters in the strings. So, for the given string calculate count of each character in an array [256]. For each word in the list, check if it contains the same count for its characters and return that word. Complexity O(n)

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

Mar 3, 2014
 How to retrieve a file with a specific string or keyword using UNIX command line3 AnswersI knew it had some thing to do with grep but was unable to give the specific line.grep -r "expression to find"find . | grep -i "String" find is generally used to find the name of the files & Grep is used to search for content present in the file

### Front End Software Engineer at eBay was asked...

Sep 25, 2012
 How would you pick the middle element of a list4 AnswersI said by dividing the length with 2. He said there would be two passes involved with that (?). He wanted some way with one pass.int[] intArray = {12,34,56,78,98,31,47}; int startIndex=0; int endIndex=intArray.length -1 ; while(startIndexits a list (assuming not an array).... Take two pointer....increment 1st pointer by 2 everytime & second by 1 [Rabbit & tortoise problem] if 1st pointer(rabbit) reaches the end of the list.... the position of the tortoise is the location of the middle element of the list.Show More ResponsesYou guys are overthinking this var arr = [1,2,3,4,5,6,7]; console.log(arr[Math.floor((arr.length - 1) / 2)]);
110 of 1,545 Interview Questions