### Accenture , Cognizant , TCS NQT 2024 Coding Questions and Solutions – Latest Placement Exam Prep

Looking to crack placement exams like Accenture 2024, Cognizant 2024, and TCS NQT 2024? This blog is your ultimate guide! We bring you the most recent coding questions from these companies’ placement exams, complete with detailed explanations and solutions. Whether it’s calculating speed, jumping to the last index, or grouping students, these coding problems cover real challenges from actual tests. Practice these questions, understand the solutions, and prepare yourself to ace your coding assessments. This blog is optimized for placement exam success with the latest questions, ensuring you’re ready to shine in 2024.

**Accenture 2024 Coding Questions: Solved with Explanations**

Are you preparing for Accenture’s 2024 placement exams? Here, we have curated some of the most recent coding questions from the exam along with their solutions. These questions are designed to help you practice efficiently and boost your chances of success. Follow along with the step-by-step solutions, and you’ll be exam-ready in no time!

**Accenture Coding Question 1: Display Number Correctly**

**Problem Statement:** Arun, a bus conductor, finds that his ticket machine prints numbers in reverse order. Help him by creating a program that displays the numbers correctly.

**Input:** `320`

**Output:** `23`

**Solution:**

`python`

def reverse_number(n):return int(str(n)[::-1])

# Example usage:print(reverse_number(320)) # Output: 23

**Accenture Coding Question 2: Sum of Even Numbers**

**Problem Statement:** Write a function that calculates the sum of even numbers in a given list of integers.

**Solution:**

def sum_of_even_numbers(lst):

return sum(num for num in lst if num % 2 == 0)

# Example usage:

numbers = [1, 2, 3, 4, 5, 6]

print(sum_of_even_numbers(numbers)) # Output: 12

**Cognizant 2024 Coding Questions: Solved with Explanations**

Looking for the latest Cognizant 2024 coding questions? You’re in the right place! These problems were asked recently in Cognizant placement exams, and we’ve provided easy-to-understand solutions that will help you ace the test.

**Cognizant Coding Question 1: Maximum People in a Lift**

**Problem Statement:** Given the maximum weight capacity of a lift and the weights of people planning to use it, find out the maximum number of people who can use the lift together without exceeding the weight capacity.

**Input:**

- Number of people (
`N`

): 3 - Maximum weight (
`X`

): 9 - Weights of people (
`A`

): (5, 1, 5)

**Output:** 2

**Solution:
**

def max_people_in_lift(N, X, A):

A.sort()

total_weight = 0

people_count = 0

for weight in A:

if total_weight + weight <= X:

total_weight += weight

people_count += 1

else:

break

return people_count

# Example usage:

print(max_people_in_lift(3, 9, [5, 1, 5])) # Output: 2

** **

**Cognizant Coding Question 2: Grouping Students for a Field Trip**

**Problem Statement:** You are organizing a field trip for students and need to divide them into two equal groups: one group with students having even-numbered IDs and the other with odd-numbered IDs. Find the maximum number of students that can be included in both groups.

**Input:**

- Number of students (
`N`

): 4 - Student IDs (
`A`

): (5, 2, 3, 6)

**Output:** 2

**Solution:**

def max_students_in_groups(N, A):

even = [x for x in A if x % 2 == 0]

odd = [x for x in A if x % 2 != 0]

return min(len(even), len(odd))

# Example usage:

print(max_students_in_groups(4, [5, 2, 3, 6])) # Output: 2

**TCS NQT 2024 Coding Questions: Solved with Explanations**

If you are preparing for the TCS NQT 2024 exam, solving the latest coding questions can greatly enhance your preparation. These coding problems were asked in recent exams, and we provide comprehensive solutions to help you get ahead.

**TCS NQT Coding Question 1: Calculate Speed**

**Problem Statement:** Find the speed of a vehicle where the distance is 1000 meters and the time is in the range of 1 to 60 seconds. The output should be in kilometers per hour (km/h).

**Solution:**

def calculate_speed(distance_m, time_s):

speed_mps = distance_m / time_s # Speed in meters per second

speed_kmph = (speed_mps * 3600) / 1000 # Convert to km/h

return speed_kmph

# Example usage:

print(calculate_speed(1000, 60)) # Output: 60.0 km/h

**TCS NQT Coding Question 2: Jump to the End of the Floor**

**Problem Statement:** Given a list of jump lengths, determine if it is possible to reach the last floor from the first one.

**Input:** `Jump = [2, 3, 1, 1, 4]`

**Output:** `True`

**Solution:**

def can_jump(jumps):

max_reach = 0

for i, jump in enumerate(jumps):

if i > max_reach:

return False

max_reach = max(max_reach, i + jump)

return True

# Example usage:

print(can_jump([2, 3, 1, 1, 4])) # Output: True

**TCS NQT Coding Question 3: Reach the Last Index Before Building Crash**

**Problem Statement:** The first index of an array should be able to reach the last index before a building crash.

**Input:** `[2, 1, 1, 3, 4]`

**Output:** `True`

**Solution:**

def can_reach_last(arr):

max_reach = 0

for i, val in enumerate(arr):

if i > max_reach:

return False

max_reach = max(max_reach, i + val)

return max_reach >= len(arr) – 1

# Example usage:

print(can_reach_last([2, 1, 1, 3, 4])) # Output: True

print(can_reach_last([3, 1, 2, 0, 4])) # Output: False

These coding questions will prepare you for your placement exams with **Accenture 2024**, **Cognizant 2024**, and **TCS NQT 2024**. By practicing these problems and reviewing the solutions, you can confidently tackle any similar coding challenges that come your way.

Don’t forget to keep practicing and stay updated with the latest coding questions to maximize your placement exam success! Happy coding and best of luck in your preparation journey!