Open In App

TCS (Ninja + Digital) Interview Experience

Round 1

The exam had MCQs and consisted of 5 sections –

  1. Aptitude
  2. Verbal Ability
  3. Logical Reasoning and Data Interpretation
  4. Pseudo-codes and programming
  5. Coding (2 Questions)

The difficulty of all the MCQs in all the sections ranged from easy to medium. But, the catch here is that for every question you had a time limit. So, you have to be quick with your calculations.



Coding Questions –

Question 1: String Compression

Problem Statement:



Given a string containing only uppercase alphabets, compress it in place such that consecutive duplicate characters are replaced with the character followed by the count of the duplicate characters. The compressed string should be returned. If the compressed string is longer than the original string, then return the original string.

Example:

Input: “AABBCCCCDD”

Output: “A2B2C4D2”

Test Cases:

Input: “AAAABBBCCDAA”

Output: “A4B3C2D1A2”

Input: “ABCD”

Output: “ABCD” (no compression since compressed string is longer than original)

Input: “AAA”

Output: “A3”

Question 2: Maximum Subarray Sum

Problem Statement:

Given an array of integers, find the contiguous subarray (containing at least one number) that has the largest sum and return the sum.

Example:

Input: [-2, 1, -3, 4, -1, 2, 1, -5, 4]

Output: 6 (the subarray [4, -1, 2, 1] has the largest sum of 6)

Test Cases:

Input: [-2, -3, 4, -1, -2, 1, 5, -3]

Output: 7 (the subarray [4, -1, -2, 1, 5] has the largest sum of 7)

Input: [1, 2, 3, 4, 5]

Output: 15 (the entire array itself is the maximum subarray)

Input: [-1, -2, -3, -4, -5]

Output: -1 (since we need to select at least one element, we select the largest negative element)

Round 2(Interview):

This was a technical interview and the panel comprised of 2 members.

  1. Tell me about yourself.
    This is a common icebreaker question. Be prepared to talk about your education, projects, work experience (if any), skills, and interests.
  2. Explain the concept of OOPs (Object-Oriented Programming).
    Be ready to discuss the principles of OOP such as encapsulation, inheritance, polymorphism, and abstraction.
  3. What is the difference between an abstract class and an interface?
    Understand the key distinctions between abstract classes and interfaces, such as the ability to define method implementations and multiple inheritances.
  4. Write a program to reverse a string in Java/Python/C++.
    This is a common coding question to assess your programming skills and understanding of string manipulation.
  5. Explain the working of the quicksort algorithm.
    QuickSort is a popular sorting algorithm. Be prepared to explain its working, time complexity, and implementation details.
  6. What is the difference between stack and queue?
    Understand the basic data structures stack and queue, and be able to explain their differences in terms of insertion, deletion, and ordering principles.
  7. Write a program to find the factorial of a number.
    This is a simple coding question to assess your understanding of loops and recursion.
  8. What are the different types of joins in SQL?
    Understand the various types of SQL joins like INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN, and be able to explain their differences and use cases.

INTERVIEW ENDS.

The Interview lasted around 30 minutes

After around 30 days the results were announced in our college WhatsApp group, 102 students out of 450 from our college got selected and I was one of them. If you have performance in the exam is outstanding then you will receive an exam link for digital upgradation.

Digital Upgradation Coding Exam.

The exam consists of only 1 round. The exam has two 2 coding questions.

Question 1: Minimum Steps to One

Problem Statement:

Given a positive integer N, you have to find the minimum number of steps to reduce it to 1. You can perform the following operations:

If N is divisible by 2, then you may reduce N to N/2.

If N is divisible by 3, then you may reduce N to N/3.

Decrement N by 1.

Example:

Input: 10

Output: 3 (10 -> 5 -> 4 -> 2 -> 1)

Test Cases:

Input: 15

Output: 4 (15 -> 5 -> 4 -> 2 -> 1)

Input: 6

Output: 2 (6 -> 3 -> 1)

Question 2: Longest Substring Without Repeating Characters

Problem Statement:

Given a string, find the length of the longest substring without repeating characters.

Example:

Input: “abcabcbb”

Output: 3 (“abc” is the longest substring without repeating characters)

Test Cases:

Input: “bbbbb”

Output: 1 (“b” is the longest substring without repeating characters)

Input: “pwwkew”

Output: 3 (“wke” is the longest substring without repeating characters)

The difficulty of the coding is medium to hard. Focus on dynamic programming and greedy algorithms.

Article Tags :