Commvault on campus coding round 1 questions

Anonymous User
32
Sep 03, 2024

In the Commvault Campus Round 1 coding , I had 25 minutes to complete 17 questions focused on OOP and pointers in C++. This involved fixing code snippets, predicting outputs, and dealing with constructors and destructors also like each question of snippet is of 15-30 lines of codes (MCQs).
After which we have 40 minutes for 3 questions . i was only able to solve question2 and half of question 1 when time was over.

1. Sterile Neutrino Problem

Problem:
A sterile neutrino is represented by a binary number with an alternating bit pattern (e.g., 101010). Given an integer n, determine how many binary numbers of with alternate 1 and 0s to the next power of 2 greater than or equal to n .

Example:

  • Input: n = 5
  • Output: 1
  • Explanation: For n = 5, the next power of 2 is 8. so 5 in binary is 101 alterate=1 , 6 in binary is 110 so alterate remains 1 , 7 in binary is 111 so no alteration alertate =1, and for 8 ,1000 , still alteration is 1. this question is something like this.

**Related LeetCode Problem:**something like this but a bit different


2. Diwali Lights Problem

Problem:
Given a set of lights with specific power consumptions and a total power requirement P, find the minimum number of lights that need to be turned off so that the total power of the remaining lights is strictly greater than P.

Example:

  • Input: n = 7, lights[] = {1, 4, 45, 6, 0, 26, 25}, P = 51
  • Output: 3
  • Explanation: Turn off lights such that the power of the remaining lights is strictly greater than 51. For instance, turning off lights 4,45, 6, and others to meet the requirement.

Related LeetCode Problem:


3. Graph Edges Problem- i am not sure about this question what was the exact words and what to do in this , i was not able to solve this so i forget what this is about.

Problem:
Given a set of nodes and edges, where nodes are represented as pairs of integers, count the number of distinct pairs of nodes (edges) in the graph.

Example:

  • Input: 0 1
    2 3
  • Output: 4
  • Explanation: The distinct pairs of nodes are (0,2), (0,3), and (1,2) ,(1,3) .

Related LeetCode Problem:

Comments (0)