ChangeCX Coding Questions and Answers

ChangeCX Coding Questions and Answers

ChangeCX is a Information Technologye and service providing company with it’s headquarters In the United States.

On this page we will discuss about ChnageCX coding question and answers which will help you in it’s Technical test during Recruitment Process

Go through the entire page to have an idea about the questions asked in ChangeCX

coding changecx

Practice ChangeCX Coding Questions and Answers

                                              Question 1: Stars Between Bars

Given a string s consisting of stars “*” and bars  “|” ,an array of starting indices starIndex, and an array of ending indices endIndex, determine the number of stars between any two bars within the substrings between the two indices inclusive . NOTE that in this problem indexing starts at 0.

  • A Star is represented as an asterisk [*=ascii decimal 42]
  • A Bar is represented as a Pipe [“|”=ascii decimal 124]

Example

s=’|**|*|’
n = 2
startIndex=[0,0]
endIndex=[4,5]

  • For the first pair of indices (0,4) the substrings is “|**|*”  . There are 2 stars between a pair of bars
  • For the second pair of indices (0,5) the substring is  “|**|*|” and there are 2+1=3 stars in between the bars.
  • Both of the answers are returned to the array [2,3].

Constraints

  • 1 <= n <= 105
  • 1 <= StartIndex[i] <= endIndex[i]
  • Each Character of s is either “*” or “|”

Input Format for Custom testing

First line contains a string S. The next line contains an integer n , the no.of elements in startIndex and endIndex. Each line i of the n subsequent lines contains an integer of startIndex. Each line i of the n subsequent lines contains an integer of endindex.

Sample Input

*|*|  → s=”*|*|”
1 → size of startindex[] and endIndex[] is 1.
0 → startindex = 0
2 → endindex = 2

Sample output:

0

Explanation :

The substring from index = 0 to index = 2 is “*|*” . there is no consecutive pair of bars in this string.

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

                                                                                     Question 2 : Duplicates

The principal has a problem with repetitions. Everytime someone sends the same email twice he becomes angry and starts yelling. His personal assistant filters the mails so that all the unique mails are sent only once, and if there is someone sending the same mail again and again, he deletes them. Write a program which will see the list of roll numbers of the student and find how many emails are to be deleted.

Input Format:

  • First line takes n, which is the total no. of mails recieved.
  • Second line takes the n no. of email id as input./li>

Output Format:

Total no. of duplicate email id’s to be deleted.

Constraints:

  • 1 <= n <= 10^4

Sample input:

  • 6   
  • 1 3 3 4 3 3

Sample output

  • 3

Question 3: Jagannath and his Brothers

Problem Statement :

Jagannath was with two of his young brothers in work. He wants to work less, and wants his brothers to work more, as he is a lazy person. Now, in the work field, there is an array of buildings, from where they can earn money. So that there arises no conflict between his brothers that who earns more, he arrives in one building, tells his brother that the very building will bring the most money (Which may not be true), and tells one of his brothers to go to the left and another one to go to the right.
You have to write a program so that you can predict which building will be getting Jagannath, and how much money each of his friends are gonna earn.

Input Format:
First line saying the number of test cases, n.
Then next n pairs of lines, first one depicting the number of buildings k and second one containing k space separated integers denoting the number of earnings possible.

Constraints
1 <= n <= 10 ^ 6
1 <= k < n
-10 ^ 9 <= a[i] <= 10 ^ 9 (Earnings)
1 <= t <= 25

Output Format:
n lines, with the index of building jagannath working, space separately the money His brothers each making. If the combination is not possible, answers are 0.

Sample Input:
1
5
1 2 2 4 5
Sample Output:
4 5
Explanation:
Jagannath will work in the 4th building, and his brothers are making 5 rupees each.

Question 4: Shushil’s Madness

Problem Statement :

Shushil has gone crazy after he lost a big amount of his money in the share market. Now he keeps all the money he has distributed in his room and calculates them in a very problematic way. Every time he calculates hisnetworth, he writes it down adding with the last 3 rooms he has one.
Then after that when he reaches the next room he adds the last 3 rooms’s money with the money found in that room and adds again. Suppose he is in ith room, he will add i-1,i-2 and i-3th rooms money with ith one and add it into his net worth (if the rooms exist).
Given an array of money in the rooms, find what will he calculate as his net worth?
Input Format:
First line saying the number of rooms, r
Next line r space separated money amounts in each room
Next line contains an m, denoting a number that we will use to take module of the final value

Constraints:

1<= r <= 1018
1<= a[i] <= min(600,r)
1<= M <= 1018

Output Format:
Print the answer on the first line

Sample Input:
5
1 2 3 4 5
100

Sample Output:
34

Question 5: Class Monitor

Problem Statement :

After JEE Mains, some students got admission into an engineering college. Now there is a class consisting of such n students, and the HOD came to say it is time to select the class monitor. But He never gets all of them at one time. So he brought a register, every time he gets someone with less rank than the previous time he cut the name and wrote the name of the student and the rank.
For a given number of ranks he gets each time, you have to predict how many names are cut in the list.

Constraints:
Number of Visiting<=10^9
ranks <=10000

Input Format:
Number of Visiting N in their first line
N space separated ranks the HOD gets each time

Output Format:
Number of ranks cut in the list

Sample Input:
6
4 3 7 2 6 1

Sample Output:
3

Question 6 : Help of Prepsters

Problem Statement :

Arnab has given me a challenge. I have to calculate the number of numbers which are less than a certain value n, and have exactly k set bits in its binary form. As you are a Prepster like me, help me write a code that will take input for n and k and give the expected output.

Constraints :
1<=n<=10000
1<=k<=10
Input Format :
First line containing n and k space separated
Output Format :
Number of numbers present in a single line

Sample Input:
7 2
Sample Output:
3
Explanation:
11,110,101 -> These three numbers.

Question 7: Majority Element

The majority element in an array is defined as the element that appears more than ⌊n/2⌋ times, where n is the length of the array.
In other words, it is the element that occurs most frequently and makes up more than half of the array.

Given an array of integers, the task is to find the majority element and return it. If there is no majority element, If there is no majority element, the algorithm should indicate that.

Examples:

Example 1:
Input: [3, 3, 4, 2, 4, 4, 2, 4, 4]
Output: 4
Explanation:
In the given array, the number 4 appears 5 times, which is more than half of the array size (9/2 = 4.5). Therefore, 4 is the majority element.

Example 2:
Input: [1, 2, 3, 4, 4, 4, 4]
Output: 4
Explanation:
In this case, the number 4 appears 4 times, which is more than half of the array size (7/2 = 3.5). Thus, 4 is the majority element.

Example 3:
Input: [1, 2, 3, 4, 5]
Output: -1
Explanation:
There is no majority element in this array since no number appears more than half of the array size (5/2 = 2.5).

Example 4:
Input: [2, 2, 2, 3, 3, 4, 4, 4, 4]
Output: -1
Explanation:
In this case, although the number 4 appears 4 times, it does not occur more than half of the array size (9/2 = 4.5).
Hence, there is no majority element.

Question 8: Smallest window in a string containing all the characters of another string

Given two strings S and P, the task is to find the smallest window in string S that contains all the characters (including duplicates) of string P. If no such window exists, return “-1”. If there are multiple windows of the same length, return the one with the smallest starting index.
Note that all characters are lowercase alphabets.

Example 1:

Input:
S = “timetopractice”
P = “toc”
Output : toprac
Explanation: The smallest substring in S that contains “toc” is “toprac”.

Example 2:
Input:

S = “zoomlazapzo”
P = “oza”

Output:
apzo
Explanation:
The smallest substring in S that contains “oza” is “apzo”.

Question 9: HR issues

Problem statement :

Shovon is an HR in a renowned company and he is assigning people to work. Now he is assigning people work in a fashion where if he assigns some work a work of cost 2, the next person will be strictly getting a job with cost equal or more than 2. Given that Shovon’s company has infinite work and a number of employees, how many distributions can be possible. The cost of jobs can go 0 to 9.

Function Description:

Complete the special_numbers function in the editor below. It has the following parameter(s):

Parameters:

Name Type Description
N Integer The number of depts.
arr[ ] Integer array The number of  employees in each dept..

Return: The function must return an INTEGER denoting the sum of answers for all distinct distributions.

Constraints:

  • 1 <= n <= 100
  • 1 <= arr[i] <= 200

Sample Cases:

  • Sample Input 1
    2
    4
    1
  • Sample Output 1
    725
  • Description
    The ans if m = 1 is 10, which is all numbers from 0 to 9
    The ans for m = 2 is 55
    The answer for m = 3 is 220
    The answer for m = 4 is 715
    So fun(4) + fun(1) = 725

Question 10: Consecutive Prime Sum

Problem Description

Question – :  Some prime numbers can be expressed as a sum of other consecutive prime numbers.

  • For example
    • 5 = 2 + 3,
    • 17 = 2 + 3 + 5 + 7,
    • 41 = 2 + 3 + 5 + 7 + 11 + 13.
      Your task is to find out how many prime numbers which satisfy this property are present in the range 3 to N subject to a constraint that summation should always start with number 2.

Write code to find out the number of prime numbers that satisfy the above-mentioned property in a given range.

Input Format: First line contains a number N

Output Format: Print the total number of all such prime numbers which are less than or equal to N.

Constraints: 2<N<=12,000,000,000

FAQ's related to ChangeCX

Question 1: What are the roles offered in ChangeCX?
The job role offered is of trainee engineer where a student needs to conduct research and collate data and provide general support to the engineering department .
Question 2: What is ChangeCX Recruitment Process?
The Online Selection Process consist of
  • Online Test (Virtual Mode)
  • Company presentation and Technical interview (On campus)
  • HR interview of selected students (On campus) 
Question 3 : What is the Eligibility Criteria for ChangeCX Recruitment Process?
The Eligibility criteria as per the placement policy of the company is  70% marks in 10th & 12th, and CGPA of 8.0 and above, with no active backlog(s).
Question 4 : What is the Package offered for Trainee Engineer role in ChangeCX?

 The Stipend during internship is INR 25,000 per month which will be of 6 months, based on performance during the internship and, if converted, to a full-time role the package is INR 10LPA

Question 5 : What are the skills that are required in this job role of ChangeCX?

 JavaScript technologies such as Nodejs, Reactjs are required in order to fullfill the skill set that is required for the role of trainee engineer in this company, Questions related to these can be asked in technical interview

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription