## Recent Interview Questions

More Questions »- 0of 0 votes
Fill the arrow with zeros in n*n matrix.{{0,0,0,0,0,0,0

0,0,1,1,1,0,0

0,0,1,0,1,0,0

0,0,1,0,1,0,0

0,1,0,0,0,1,0

0,0,1,0,1,0,0

0,0,0,1,0,0,0}}

- 0of 0 votes
Given an integer n, replace its bits starting from the bit at position a to the bit at position b, inclusive, with the bits of integer k. Count from the least significant bit to the most significant bit, starting from 0.

Example:

For n = 1024, a = 1, b = 6 and k = 17, the output should be

insertBits(n, a, b, k) = 1058.

n = 100 0000 00002, k = 1 00012, 1058 = 100 0010 00102.

For n = 11, a = 1, b = 2 and k = 2, the output should be

insertBits(n, a, b, k) = 13.

n = 10112, k = 102, 13 = 11012.

- 0of 0 votes
Given a math expression in string format that contains only + & - and numbers. Return the sum in integer format. Eg: Input: "3+4-7+13" Output: 13.

"2+1-8+13" Output: 8

- 0of 0 votes
Implement a function that takes two strings, s and x, as arguments and finds the first occurrence of the string x in s. The function should return an integer indicating the index in s of the first occurrence of x. If there are no occurrences of x in s, return -1.

Example:

For s = "AGoogleInterviewIsAwesome" and x = "IA", the output should be

strstr(s, x) = -1;

For s = "AGoogleIsAwesome" and x = "IsA", the output should be

strstr(s, x) = 10.

Apparently, my solution was not efficient enough with string lengths that are 2000+:`int findFirstSubstringOccurrence(String s, String x) { int sLen = s.length(); int xLen = x.length(); int tracker = 0; if (sLen == xLen) { if (s.equals(x)) { return 0; } else { return -1; } } else { if (xLen >= 1) { for (int index = 0; index < sLen; index++) { if (s.charAt(index) == x.charAt(tracker)) { tracker++; if (tracker == xLen) { return index - (xLen - 1); } } else { index -= tracker; tracker = 0; } } } } return -1; }`

- 0of 0 votes
An n * m matrix represents an array of computers, giving you a List <int []> that represents the coordinates of the broken computer.

Now we start from (0,0) repair computer requirements:

1. You must finish all the broken computers in the current line to get to the next line

2. To go to the next line, the mechanic must first return to the far left or right of this line

And then find repair each computer order that has the minimum access distance,