Autocoder

Zoho Coding Round Questions with Solutions

Last updated 2026-11-19

Zoho's programming rounds are described as requiring working code, first at a basic level and then at an advanced level. Typical practice for them is not obscure algorithms but careful implementation: strings, matrices, number logic and small simulations such as a board game. This page has eleven such practice problems with Python and Java.

They are original practice problems in that style, not past questions. Read Zoho interview questions for aptitude and concepts, and the online assessment guide for habits that help in any coding test.

What the programming rounds reward

A FACE Prep guide describes a basic programming round where working code is required and an advanced round with harder problems. In practice, that means handling input and output yourself, covering edge cases, and not relying on library one-liners you cannot explain.

Practise without autocomplete. Write the loop bounds and index arithmetic carefully; most failures in this style of problem are off-by-one errors, not wrong ideas.

Hiring status

Zoho does not publish a fixed schedule for drives. Check careers.zohocorp.com for the current openings. The process above is from a third-party guide.

Zoho Coding Round Questions with Solutions: questions with worked answers

  1. 1

    Print a matrix in spiral order.

    medium

    A staple of implementation rounds that tests boundary handling. Maintain four boundaries (top, bottom, left, right). Walk the top row, right column, bottom row and left column, shrinking the boundary after each, and stop when they cross. O(R*C) time, O(1) extra space. Common mistakes: Repeating the middle row or column on non-square matrices because the bottom and left passes are not guarded by a boundary check.

    python
    def spiral(m):
        out = []
        t, b, l, r = 0, len(m) - 1, 0, len(m[0]) - 1
        while t <= b and l <= r:
            out += m[t][l:r+1]
            t += 1
            for i in range(t, b + 1): out.append(m[i][r])
            r -= 1
            if t <= b:
                out += m[b][l:r+1][::-1]
                b -= 1
            if l <= r:
                for i in range(b, t - 1, -1): out.append(m[i][l])
                l += 1
        return out
    java
    import java.util.*;
    class Solution {
        List<Integer> spiral(int[][] m) {
            List<Integer> out = new ArrayList<>();
            int t = 0, b = m.length - 1, l = 0, r = m[0].length - 1;
            while (t <= b && l <= r) {
                for (int j = l; j <= r; j++) out.add(m[t][j]);
                t++;
                for (int i = t; i <= b; i++) out.add(m[i][r]);
                r--;
                if (t <= b) { for (int j = r; j >= l; j--) out.add(m[b][j]); b--; }
                if (l <= r) { for (int i = b; i >= t; i--) out.add(m[i][l]); l++; }
            }
            return out;
        }
    }
  2. 2

    Rotate an n by n image 90 degrees clockwise in place.

    medium

    Matrix work without extra memory. A clockwise rotation equals a transpose followed by reversing each row. Do both in place. O(n^2) time, O(1) space. Common mistakes: Reversing rows before transposing gives the anticlockwise result, and transposing the whole matrix twice undoes the work.

    python
    def rotate(m):
        n = len(m)
        for i in range(n):
            for j in range(i + 1, n):
                m[i][j], m[j][i] = m[j][i], m[i][j]
        for row in m: row.reverse()
    java
    class Solution {
        void rotate(int[][] m) {
            int n = m.length;
            for (int i = 0; i < n; i++)
                for (int j = i + 1; j < n; j++) { int t = m[i][j]; m[i][j] = m[j][i]; m[j][i] = t; }
            for (int[] row : m)
                for (int i = 0, j = n - 1; i < j; i++, j--) { int t = row[i]; row[i] = row[j]; row[j] = t; }
        }
    }
  3. 3

    Print the first n rows of Pascal's triangle.

    easy

    A pattern problem that hides a simple recurrence. Each row starts and ends with 1 and every inner value is the sum of the two values above it. Build row by row from the previous row. O(n^2) time and output size. Common mistakes: Index errors at the ends of each row.

    python
    def pascal(n):
        rows = [[1]]
        for _ in range(n - 1):
            p = rows[-1]
            rows.append([1] + [p[i] + p[i+1] for i in range(len(p) - 1)] + [1])
        return rows
    java
    import java.util.*;
    class Solution {
        List<List<Integer>> pascal(int n) {
            List<List<Integer>> rows = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                List<Integer> r = new ArrayList<>();
                for (int j = 0; j <= i; j++)
                    r.add(j == 0 || j == i ? 1 : rows.get(i - 1).get(j - 1) + rows.get(i - 1).get(j));
                rows.add(r);
            }
            return rows;
        }
    }
  4. 4

    Compress a string by replacing runs with counts, such as aabccc to a2bc3.

    easy

    String traversal with run detection. Walk the string, counting runs of equal characters, and emit the character followed by the count when it is greater than one. O(n) time, O(n) space. Common mistakes: Forgetting to flush the last run after the loop ends.

    python
    def compress(s):
        out, i = [], 0
        while i < len(s):
            j = i
            while j < len(s) and s[j] == s[i]: j += 1
            out.append(s[i] + (str(j - i) if j - i > 1 else ''))
            i = j
        return ''.join(out)
    java
    class Solution {
        String compress(String s) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0, j; i < s.length(); i = j) {
                j = i;
                while (j < s.length() && s.charAt(j) == s.charAt(i)) j++;
                sb.append(s.charAt(i));
                if (j - i > 1) sb.append(j - i);
            }
            return sb.toString();
        }
    }
  5. 5

    Reverse the order of words in a sentence.

    easy

    Basic string handling. Split on whitespace, reverse the list of words and join with single spaces. Splitting with no argument also removes extra spaces. O(n) time, O(n) space. Common mistakes: Splitting on a single space, which leaves empty strings when there are repeated spaces.

    python
    def reverse_words(s):
        return ' '.join(reversed(s.split()))
    java
    import java.util.*;
    class Solution {
        String reverseWords(String s) {
            String[] w = s.trim().split("\\s+");
            Collections.reverse(Arrays.asList(w));
            return String.join(" ", w);
        }
    }
  6. 6

    First non-repeating character in a string.

    easy

    Counting characters, two passes. Count each character in a first pass, then scan again and return the first index whose count is one. O(n) time, O(alphabet) space. Common mistakes: Returning the first key of the count map, which need not follow string order.

    python
    from collections import Counter
    def first_unique(s):
        c = Counter(s)
        for i, ch in enumerate(s):
            if c[ch] == 1: return i
        return -1
    java
    class Solution {
        int firstUnique(String s) {
            int[] c = new int[256];
            for (char ch : s.toCharArray()) c[ch]++;
            for (int i = 0; i < s.length(); i++) if (c[s.charAt(i)] == 1) return i;
            return -1;
        }
    }
  7. 7

    Convert a Roman numeral to an integer.

    easy

    Rule-based parsing. Scan left to right; if a symbol is smaller than the one after it, subtract it, otherwise add it. O(n) time, O(1) space. Common mistakes: Handling only the six special pairs by hand instead of using the smaller-before-larger rule.

    python
    def roman(s):
        v = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
        t = 0
        for i, ch in enumerate(s):
            t += -v[ch] if i + 1 < len(s) and v[ch] < v[s[i+1]] else v[ch]
        return t
    java
    import java.util.*;
    class Solution {
        int roman(String s) {
            Map<Character, Integer> v = Map.of('I', 1, 'V', 5, 'X', 10, 'L', 50, 'C', 100, 'D', 500, 'M', 1000);
            int t = 0;
            for (int i = 0; i < s.length(); i++) {
                int x = v.get(s.charAt(i));
                t += (i + 1 < s.length() && x < v.get(s.charAt(i + 1))) ? -x : x;
            }
            return t;
        }
    }
  8. 8

    List all primes up to n.

    easy

    Number logic with the sieve. Mark multiples of each prime as composite starting at p*p, up to the square root of n. The unmarked numbers are the primes. O(n log log n) time, O(n) space. Common mistakes: Starting the inner loop at 2*p (correct but slower) and forgetting that 0 and 1 are not prime.

    python
    def primes(n):
        if n < 2: return []
        s = [True] * (n + 1)
        s[0] = s[1] = False
        for p in range(2, int(n ** 0.5) + 1):
            if s[p]:
                for m in range(p * p, n + 1, p): s[m] = False
        return [i for i, v in enumerate(s) if v]
    java
    import java.util.*;
    class Solution {
        List<Integer> primes(int n) {
            boolean[] comp = new boolean[n + 1];
            List<Integer> out = new ArrayList<>();
            for (int p = 2; p <= n; p++) {
                if (comp[p]) continue;
                out.add(p);
                for (long m = (long) p * p; m <= n; m += p) comp[(int) m] = true;
            }
            return out;
        }
    }
  9. 9

    Count the set bits in an integer.

    easy

    Bit tricks. Brian Kernighan's trick: n & (n - 1) clears the lowest set bit, so the number of iterations equals the number of set bits. O(set bits) time, O(1) space. Common mistakes: Looping 32 times with shifts and mishandling negative numbers (use an unsigned shift in Java).

    python
    def count_bits(n):
        c = 0
        while n:
            n &= n - 1
            c += 1
        return c
    java
    class Solution {
        int countBits(int n) { int c = 0; while (n != 0) { n &= n - 1; c++; } return c; }
    }
  10. 10

    Find the longest palindromic substring.

    medium

    Expand-around-centre. Expand around each centre: every index (odd length) and every gap between indices (even length). Keep the longest range found. O(n^2) time, O(1) space. Common mistakes: Checking only odd-length centres, and returning the length when the substring itself was asked for.

    python
    def longest_pal(s):
        best = ''
        for c in range(len(s)):
            for l, r in ((c, c), (c, c + 1)):
                while l >= 0 and r < len(s) and s[l] == s[r]:
                    l -= 1; r += 1
                if r - l - 1 > len(best): best = s[l+1:r]
        return best
    java
    class Solution {
        String longestPal(String s) {
            int bs = 0, bl = 0;
            for (int c = 0; c < s.length(); c++)
                for (int k = 0; k < 2; k++) {
                    int l = c, r = c + k;
                    while (l >= 0 && r < s.length() && s.charAt(l) == s.charAt(r)) { l--; r++; }
                    if (r - l - 1 > bl) { bl = r - l - 1; bs = l + 1; }
                }
            return s.substring(bs, bs + bl);
        }
    }
  11. 11

    Game simulation: minimum dice throws to finish a snake and ladder board.

    medium

    A board game that checks modelling skill. Treat each square 1..100 as a node with edges to the next six squares, following any snake or ladder at the landing square. BFS from square 1 gives the minimum dice throws. O(N) time and space for an N-square board. Common mistakes: Applying a snake or ladder twice in one move, and using DFS, which does not give shortest paths.

    python
    from collections import deque
    def min_throws(jump, n=100):  # jump: {from_square: to_square}
        seen, q = {1}, deque([(1, 0)])
        while q:
            sq, d = q.popleft()
            if sq == n: return d
            for step in range(1, 7):
                nx = sq + step
                if nx > n: continue
                nx = jump.get(nx, nx)
                if nx not in seen:
                    seen.add(nx)
                    q.append((nx, d + 1))
        return -1
    java
    import java.util.*;
    class Solution {
        int minThrows(Map<Integer, Integer> jump, int n) {
            boolean[] seen = new boolean[n + 1];
            Deque<int[]> q = new ArrayDeque<>();
            q.add(new int[]{1, 0});
            seen[1] = true;
            while (!q.isEmpty()) {
                int[] c = q.poll();
                if (c[0] == n) return c[1];
                for (int s = 1; s <= 6 && c[0] + s <= n; s++) {
                    int nx = jump.getOrDefault(c[0] + s, c[0] + s);
                    if (!seen[nx]) { seen[nx] = true; q.add(new int[]{nx, c[1] + 1}); }
                }
            }
            return -1;
        }
    }

Frequently asked questions

Are library functions allowed in Zoho coding rounds?

Rules vary by round. Learn to solve without relying on them so you are safe either way.

What language do most candidates use?

C, C++, Java and Python are all common. Pick the one where you make fewest syntax slips.

How many problems are there in the programming rounds?

Public guides differ, and Zoho does not publish it. Follow your invitation.

How do I practise implementation problems?

Write full programs with input handling on paper or in a plain editor, then test edge cases such as empty and single-element inputs.

Sources

Related guides

More in Company Interview Questions

See all in this section