Add office photos
Engaged Employer

CGI Group

4.1
based on 4k Reviews
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards

Top 332 Interview Questions and Answers 2024

Updated on 10 Sep 2024
Q1. Compress the String Ninja has been given a program to do basic string compression. For a character that is consecutively repeated more than once, he needs to replace the consecutive duplicate occurrences with the count of repetitions. Example: If a string has 'x' repeated 5 times, replace this "xxxxx" with "x5". The string is compressed only when the repeated character count is more than 1. Note : The consecutive count of every character in the input string is less than or equal to 9. Input Format: The first line contains an integer 'T' which denotes the number of test cases or queries to be run. The first line of each test case contains one string ‘S’ denoting the input string that needs to be compressed. Output...read more
View Answers (3)
Q2. Frog Jump There is a frog on the 1st step of an N stairs long staircase. The frog wants to reach the Nth stair. HEIGHT[i] is the height of the (i+1)th stair.If Frog jumps from ith to jth stair, the energy lost in the jump is given by |HEIGHT[i-1] - HEIGHT[j-1] |.In the Frog is on ith staircase, he can jump either to (i+1)th stair or to (i+2)th stair. Your task is to find the minimum total energy used by the frog to reach from 1st stair to Nth stair. For Example If the given ‘HEIGHT’ array is [10,20,30,10], the answer 20 as the frog can jump from 1st stair to 2nd stair (|20-10| = 10 energy lost) and then a jump from 2nd stair to last stair (|10-20| = 10 energy lost). So, the total energy lost is 20. Input Format: Th...read more
View Answers (4)
Q3. Palindromic Substrings You have been given a string STR. Your task is to find the total number of palindromic substrings of STR. Example : If the input string is "abbc", then all the possible palindromic substrings would be: ["a", "b", "b", c", "bb"] and hence, the output will be 5 since we have 5 substrings in total which form a palindrome. Note : A string is said to be a 'Palindrome' if it is read the same forwards and backwards. For example, “abba” is a palindrome, but “abbc” is not. A 'Substring' is a contiguous sequence of characters within a string. For example, "a", "b", "c", "ab", "bc", "abc" are substrings of "abc". Input format : The first line contains an integer 't' which denotes the number of test cas...read more
View Answers (6)
Discover interview dos and don'ts from real experiences
Q4. Anagram Pairs Pre-requisites: Anagrams are defined as words or names that can be formed by rearranging letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "rasp" are anagrams. Other examples include: 'triangle' and 'integral' 'listen' and 'silent' Now, Coding Ninjas has the following task for you: You would be given two strings. You have to tell whether these strings form an anagram pair or not. The strings form an anagram pair if the letters of one string can be rearranged to form another string. Note: Since it is a binary problem, there is no partial marking. Marks will only be awarded if you get all the test cases correct. Input format: The first and the only...read more
View Answers (3)
Q5. Power Set You are given a sorted array of 'N' integers. You have to generate the power set for this array where each subset of this power set is individually sorted. A set is a well-defined collection of distinct elements. Power set P(ARR) of a set 'ARR' is defined as a set of all possible subsets of 'ARR'. You have to return the array of subsets. The elements in the subset should be sorted in ascending order. The order of subsets in the array does not matter. Hence there can be more than 1 possible solution for a given array. For example : If we are given an array ARR=[1,2,3] then the power set P(ARR) of the set ARR is: [ [], [1], [2], [1,2], [3], [1,3], [2,3], [1,2,3] ] Note : For every subset 'X' present in powe...read more
View Answers (4)
Q6. Pythagorean Triplets You are given an array of n integers (a1, a2,....,an), you need to find if the array contains a pythagorean triplet or not. An array is said to have a pythagorean triplet if there exists three integers x,y and z in the array such that x^2 + y^2 = z^2. Note 1. The integers x,y and z might not be distinct , but they should be present at different locations in the array i.e if a[i] = x, a[j] = y and a[k] = z, then i,j and k should be pairwise distinct. 2. The integers a,b and c can be present in any order in the given array. Input Format: The first line contains a single integer t - the number of test cases. Each test case consists of 2 lines as follows: The first line of each test case will conta...read more
View Answers (4)
Share interview questions and help millions of jobseekers 🌟
Q7. Intersection of Linked List You are given two Singly Linked List of integers, which are merging at some node of a third linked list. Your task is to find the data of the node at which merging starts. If there is no merging, return -1. For example:- The given Linked Lists, where a1, a2, c1 is the first linked list, b1, b2, b3, c1 is the second linked list, and c1, c2, c3 is the third linked list which are merging at node c1. Input Format: The input format contains three lines consisting of three singly-linked lists. All three lines contain the elements of the singly linked list separated by a single space and terminated by -1. So first linked list would contain a1, a2, ...an, c1, -1. Similarly, the second line woul...read more
View Answers (4)
Q8. Preorder traversal of a BST You have been given an array/list 'PREORDER' representing the preorder traversal of a BST with 'N' nodes. All the elements in the given array have distinct values. Your task is to construct a binary search tree that matches the given preorder traversal. A binary search tree (BST) is a binary tree data structure that has the following properties: • The left subtree of a node contains only nodes with data less than the node’s data. • The right subtree of a node contains only nodes with data greater than the node’s data. • Both the left and right subtrees must also be binary search trees. Note: It is guaranteed that a BST can be always constructed from the given preorder traversal. Hence, t...read more
View Answers (3)
Q9. Remove Vowels You are given a string STR of length N. Your task is to remove all the vowels present in that string and print the modified string. English alphabets ‘a’, ‘e’, ‘i’, ‘o’, ‘u’ are termed as vowels. All other alphabets are called consonants. Note: You have to only remove vowels from the string. There will be no change in the relative position of all other alphabets. For example: (i) If the input string is 'CodeGeek', the output should be CdGk after removing ‘o’ and ‘e’. (ii) If the input string is 'Odinson', the output should be 'dnsn' after removing ‘o’ and ‘i’. Input Format: The first line of input contains an integer 'T' representing the number of the test case. Then the test case follows. The first an...read more
View Answers (3)
Q10. Spiral Matrix You are given a N x M matrix of integers, print the spiral path of the matrix. For example: Input Format: The first line contains an integer 'T' which denotes the number of test cases or queries to be run. Then the test cases follow. The first line of each test case contains two single space-separated integers N and M, denoting the number of rows and columns respectively. The next 'N' lines, each contains 'M' single space-separated integers representing the elements in a row of the matrix. Output format : For each test case/query, print the spiral path of the given matrix. Output for every test case will be printed in a separate line. Note: You do not need to print anything, it has already been taken...read more
View Answers (4)
Q11. Java Question What are the various access specifiers in Java? ...read more
View Answer (1)
Q12. Two Sum You are given an array of integers 'ARR' of length 'N' and an integer Target. Your task is to return all pairs of elements such that they add up to Target. Note: We cannot use the element at a given index twice. Follow Up: Try to do this problem in O(N) time complexity. Input Format: The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the test case follows. The first line of each test case contains two single space-separated integers ‘N’ and ‘Target’ denoting the number of elements in an array and the Target, respectively. The second line of each test case contains ‘N’ single space-separated integers, denoting the elements of the array. Output Format : For each te...read more
View Answers (2)
Q13. Concatenate the largest digit You are given three non-zero numbers ‘A’, ‘B’, and ‘C’. The task is to find the number formed by concatenating the largest digit from each of these numbers in the order of ‘A’, ‘B’, and ‘C’. For Example : A = 5678, B = 45 and C = 769 The largest digit in ‘A’ is ‘8’, ‘B’ is ‘5’, and ‘C’ is ‘9’. The new number formed by concatenating the largest digit from each of these numbers is ‘859’. So, the answer is ‘859’. Input Format : The first line of input contains an integer ‘T’ which denotes the number of test cases. Then, the ‘T’ test cases follow. The first and only line of each test case contains three space-separated numbers, ‘A’, ‘B’, and ‘C’, denoting the given numbers. Output Format ...read more
View Answers (2)
Q14. Java Question How many types of memory areas are allocated by JVM? ...read more
View Answer (1)
Q15. 1,Diff bwn aggregation and composition? 2,w a p to print fibnoci sries? with recursion? 3,Diff bwn interface and abstract? 4,w ap to print * patteren? * ** *** **** 5,Explain custom immutable class? 6,what is immutable? 7,what is singleton?w ap for single ton? 8,how can threads communicates each other? 9,what is diff bwn t.start() and t.run()? 10,what is thread priority? 11,what is deadlock?how can u avoid deadlock? ...read more
View Answer (1)
Q16. Design Pattern Question What are the types of design patterns in Java? ...read more
View Answer (1)
Q17. Spring Boot Question What is the purpose of using @ComponentScan in the class files? ...read more
View Answer (1)
Q18. Java Question What do you know about JIT compiler? ...read more
View Answer (1)
Q19. Spring Boot Question What Are the Basic Annotations that Spring Boot Offers? ...read more
View Answer (1)
Q20. OOPS, DBMS, OS Questions OOPS concepts with real time example SQL statements paper based Pointers are available in java if not available why Diff between unions and structures Concept on procedures and functions in pl/sql Major diff between procedures and functions in pl/sql Views concept in DBMS OSI LAYERS briefly ...read more
Add Answer
1
2
3
4
5
6
7

More about working at CGI Group

Top Rated Company for Women - 2024
Top Rated IT/ITES Company - 2024
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Top CGI Group Interview Questions And Answers
Share Interview Advice
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 Lakh+

Reviews

4 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2023 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter