## Recent Interview Questions

More Questions »- 2of 2 votes
Jet.com

Print a matrix in zigzag traversal (diagonally).

For matrix

1 2 3 4 5 6

7 8 9 10 11 12

13 14 15 16 17 18

19 20 21 22 23 24

Print

1 2 7 13 8 3 4 9 14 19 20 15 10 5 6 11 16 21 22 17 12 18 23 24

- 0of 0 votes
Evaluate infix expression: 2 + 3 * 5

- 0of 0 votes
Interleave two singly linked lists into one.

LL1: 1 -> 2 -> 3 -> 4

LL2: 10 -> 20 -> 30 -> 40 ->50

Output LL1: 1-> 10 -> 2 -> 20 -> 3 -> 30 -> 4.

Note: Stop when we hit null for LL1.

- 0of 0 votes
Given: Collection of sorted (ascending) iterators which return integer value.

Implement hasNext() and next() methods in SuperIterator class that next() method should return sorted values from all iterators.

Note that we can't load all iterators to memory, because they might get values from big file (1TB for instance) and it will lead to OutOfMemoryError.`/* iter1: 1, 4, 5, 20, ... iter2: 2, 10, 12, 50, ... SuperIterator.next() method should return: 1, 2, 4, 5, 10, 12, 20, 50, ... */ interface Iterator { boolean hasNext(); int next(); } class SuperIterator { public SuperIterator(Collection<Iterator> iters) { } boolean hasNext() { //TODO } int next() { //TODO } }`

- 0of 0 votes
We say that a character is unique in string S if it occurs exactly once in it. For example, in string S = "ACAX", the only unique characters are "C" and "X".

Let's define UNI(S) as the number of unique characters in string S. For example, UNI("ACAX") equals 2.

Given a string S, calculate the sum of UNI(S') over all non-empty substrings S'. If there are two or more equal substrings at different positions in S, we consider them different.

Since the answer can be very large, provide it modulo 1,000,000,007 (109 + 7).

Write a function:

class Solution { public int solution(String S); }

that, given a non-empty string S consisting of uppercase letters, returns the sum of UNI(S') over all non-empty substrings S' of S modulo 1,000,000,007.

For example, given "ACAX", your function should return 16, as explained visually as follows:

UNI("A") = 1

UNI("AC") = 2

UNI("ACA") = 1

UNI("ACAX") = 2

UNI("C") = 1

UNI("CA") = 2

UNI("CAX") = 3

UNI("A") = 1

UNI("AX") = 2

UNI("X") = 1

Total: 16

Given "CODILITY", your function should return 96.

Assume that:

the length of S is within the range [4..100,000];

string S consists only of uppercase letters (A−Z).

Complexity:

expected worst-case time complexity is O(N);

expected worst-case space complexity is O(N) (not counting the storage required for input arguments).