ConsultAdd Inc interview experience Real time questions & tips from candidates to crack your interview

Software Engineer

ConsultAdd Inc
upvote
share-icon
1 rounds | 2 Coding problems

Interview preparation journey

expand-icon
Journey
I prepared for this company by reviewing previous interview experiences shared online and practicing coding problems on platforms like LeetCode and GeeksforGeeks.
Preparation
Topics: DSA, Javascript, OS
Application process
Where: Coding Ninjas Placement Cell
Eligibility: B.Tech CS/IT (Grad Year-2025 & 2024)

Interview rounds

01
Round
Medium
Online Coding Interview
Duration
Interview date7 Mar 2025
Coding problem2

1. Count Total Car Collisions on a Road

You are given a 0-indexed string directions of length n. Each character in directions[i] can be:

  • 'L' — car moving left
  • 'R' — car moving right
  • 'S' — car staying at its current point

All moving cars travel at the same speed. Collisions are counted as follows:

  1. When two cars moving in opposite directions collide, the number of collisions increases by 2.
  2. When a moving car collides with a stationary car, the number of collisions increases by 1.

After a collision, the cars involved stop at the collision point and cannot move further. Cars cannot change their direction or state otherwise.

Task: Return the total number of collisions that will occur on the road.

Problem approach

Step 1: Read the input string. 

Step 2: Initialize variables. For example collisions: to keep track of the total number of collisions. moveRight: to count consecutive R cars moving right. stationaryFound: a boolean flag to check if any stationary car (S) is encountered. 

Step 3: Iterate through each car direction. Used a for loop to iterate through the directions string. 

Step 4: Handle R cars (moving right). If the car is R, increment moveRight to track right-moving cars. 

Step 5: Handle L cars (moving left). If a L car is found: If there were previous R cars, they collide. Add moveRight + 1 collisions (current L + all previous R cars). Reset moveRight to 0. If a stationary car was previously found, add 1 collision (L hits S). 

Step 6: Handle S cars (stationary). Add all previous R cars as collisions. Reset moveRight to 0. Set stationaryFound to true to track future L cars colliding with S. 

Step 7: Print the result.Display the total number of collisions using System.out.print(collisions).

2. Longest Wiggle Subsequence

A wiggle sequence is a sequence of numbers where the differences between successive numbers strictly alternate between positive and negative. The first difference (if it exists) may be either positive or negative.

A sequence with one element or two non-equal elements is trivially a wiggle sequence.

Examples:

  • [1, 7, 4, 9, 2, 5] is a wiggle sequence because the differences (6, -3, 5, -7, 3) alternate between positive and negative.
  • [1, 4, 7, 2, 5] is not a wiggle sequence because its first two differences are both positive.
  • [1, 7, 4, 5, 5] is not a wiggle sequence because it has a difference of zero.

Task: Given an integer array, determine the length of the longest wiggle subsequence.

Problem approach

Step 1: Import necessary libraries: java.util.*. 

Step 2: Define the wiggleMaxLength function to calculate the longest wiggle subsequence. 

Step 3: Handle edge cases: return the size if the list has fewer than 2 elements. 

Step 4: Initialize variables: prevDiff = 0 and count = 1. 

Step 5: Iterate through the list, calculating the difference between consecutive numbers. 

Step 6: Check for alternating signs: If positive follows negative or vice versa, increment count. Update prevDiff with the current difference. 

Step 7: Return the final count of the longest wiggle subsequence.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is recursion?

Choose another skill to practice
Similar interview experiences
Software Engineer
1 rounds | 2 problems
Interviewed by ConsultAdd Inc
53 views
0 comments
0 upvotes
Software Engineer
1 rounds | 1 problems
Interviewed by ConsultAdd Inc
53 views
0 comments
0 upvotes
Software Engineer
1 rounds | 2 problems
Interviewed by ConsultAdd Inc
49 views
0 comments
0 upvotes
Software Engineer
1 rounds | 1 problems
Interviewed by ConsultAdd Inc
47 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Software Engineer
4 rounds | 1 problems
Interviewed by Newgen Software
3210 views
2 comments
0 upvotes
company logo
Software Engineer
3 rounds | 6 problems
Interviewed by HashedIn
2582 views
0 comments
0 upvotes
company logo
Software Engineer
2 rounds | 2 problems
Interviewed by Ernst & Young (EY)
0 views
0 comments
0 upvotes