Impetus Technologies Latest Coding Questions with Solutions

Impetus Technologies Previously Asked coding Questions for Associate Software Engineer

About Impetus :
Impetus is a product development, software services and solutions company focused on creating new ways of analyzing data for businesses, thereby helping them gain key business insights across the enterprise .

Here in this blog we discuss some Previously Asked coding Question Impetus recruitment exams , Impetus coding question 2021/22, Impetus Coding questions in java, Impetus coding solutions, Impetus Test pattern, Impetus selection process, Impetus written test questions.

Selection Process :

There were basically 4 Rounds conducted at Impetus Technologies
  1.  Written Round 
  2.  Technical Round-I
  3.  Technical Round-II 
  4.  HR Round
  • Written Round: This round was for 1.5 hours and had 2 coding questions to be solved and 2 SQL queries were to be written. Both coding questions were easy and the SQL queries were medium to difficult range.
  • Technical Round 1: This round went for about 1 hour. The interviewer started with the introduction.
  • Technical Round 2: The interviewer straight away jumped to the Advance concept questions
  • HR Round: Basic HR questions like will you be able to relocate after pandemic. That’s it.

Academic Criteria: 

  • Candidate must be a B.Tech (C.S /I.T). 
  • 70 percent throughout (Class X , XII and Graduation). 
  • Education gap of not more than one year.

Impetus Question 1 :Table of Contains

Create a table of contains for a simple markup language. It must follow two rules:
1. If a line start with a single # followed by a space, then it's a chapter title.
2 If a line stats with a double # followed by a space then it's a section title.
The table of contains should be displayed in the following format:
1. Title of the first chapter
1.1. Title of the fist section pf the first chapter
1.2. Title of the second section of the first chapter
...
2. Title of the second chapter
2.1 Title of the first section of the second chapter
2.2. Title of the second section of the second chapter
...
Function Description
Complete the function tableOfContains in the editor below
tableOfContents has the following parameter
Returns
string[]: each string is a line in the table of contents
Constraints :
1 <= n <= 1000
1 <= length of text[i] <= 100
When a line start with # or with ## these spacial characters are always followed by a space.
The first line of the text is guarantees to be a chapter line.

Solution

import java.util.Scanner;
public class Solution2 {
  static int c1 = 1;
  static int c2 = 0;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.nextLine();
    for(int i=1; i<=n; i++) {
      String s1 = sc.nextLine();
      if((s1.charAt(0) == '#') &&(s1.charAt(1)!='#')){
        System.out.println(++c2+"."+s1.substring(1,s1.length()));
        c1 = 1;
      }else {
        System.out.println(c2+"."+c1+" "+s1.substring(1,s1.length()));
        c1++;  
      }
    }
  }
}

Impetus Question 2: String Reduction:

Given a string, reduce it in such a way that all of its substring are district. To do so you many delete any character at any index.
What is the minimum number of deletions needed?
Note: A substring is a contiguous group of 1 or more character within a string. Example
s = "abab"
Substring in s are {"a","b","a", "b", "ab", "ba","ab","aba","bab","abab"}. By deleting one "a" and one "b", the string become "ab" or "ba" and all of its substring are distinct .This required 2 deletions.
Function Description
Complete the function getMinDeletions in the editor below.
getMinDeletions has the following parameters(s):
string s: the given string
Returns: int: the minimum number of deletions required
Constraints
1 <= n <=105
Sample Input
abcab
Sample Output
2

Solution

public class Solution1 {
  static final int MAX_CHAR = 26;
  public static int minChanges(String str) {
    int n = str.length();
    if (n > MAX_CHAR)
      return -1;
    int dist_count = 0;
    int count[] = new int[MAX_CHAR];
    for (int i = 0; i < MAX_CHAR; i++)
      count[i] = 0;
    for (int i = 0; i < n; i++) {
      if (count[str.charAt(i) - 'a'] == 0)
        dist_count++;
      count[str.charAt(i) - 'a']++;
    }
    return (n - dist_count);
  }
  public static void main(String[] args) {
    String str = "abcab";
    System.out.println(minChanges(str));
  }
}

Impetus Question 3 : Palindrome Prefix

A Special palindrome is a palindrome of size N which contains most K distinct character such that any prefix of size between and N-1 is not a palindrome.
For example abba is a special palindrome with N=4 and K=2 ababa is not a special palindrome because aba is a palindrome its a prefix of ababa.
Task
Count the number of special palindromes.
Example
Assumptions
N = 3
k = 3
Approach
All possible special palindromes are aba, aca,bab,bcb,cac and cbc
Hence the answered is 6.
Input
3
3
Output
6

Solutions

public class Main{
   public static long prefix_Palindrom(int N,int K){
        int M  = 1000000000+9;
        long[] dp = new long[N+1];
        dp[1] = K;
       
        for(int i=2; i<=N; i++){
             if(i%2 == 1){
                 dp[i] = ((K * dp[i-1]) % M - dp[(i+1)/2] + M )%M;
             }else{
                 dp[i] = dp[i-1];
             }
        }
        return dp[N];
    
    }
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();

      System.out.println(prefix_Palindrom(N,K));
   }
}

Question 4 : coming soon!

Comments

More Related

For Any Help Related to coding exams follow me on Instagram : codingsolution75

Popular Posts

WIPRO Latest Coding Questions with Solutions : 2023

EPAM Latest Coding Questions with Solutions 2023

MindTree Latest Coding Questions with Solutions

Fresco Play Hands-on Latest Solutions

TCS Digital Exam | DCA | Direct Capability Assessment

TCS Wings 1 All Prerequisite

Infosys | InfytTq | Infosys Certification Exam Latest Coding Questions with Solutions

RAKUTEN Latest Coding Questions with Solutions

Cognizant

TypeScript Complete Course With Completed Hands-on