Add office photos
Engaged Employer

MagicBricks

3.4
based on 708 Reviews
Video summary
Filter interviews by

P-Mech Consultant Interview Questions and Answers

Updated 5 Feb 2024

Q1. Sort 0 1 2 Problem Statement

Given an integer array arr of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.

Input:

The first line contains an integer 'T' representing the number of...read more
Ans.

Sort an integer array containing only 0s, 1s, and 2s in linear time complexity.

  • Use three pointers to keep track of the positions of 0s, 1s, and 2s in the array.

  • Iterate through the array and swap elements based on the values encountered.

  • Achieve sorting in a single scan over the array without using any extra space.

Add your answer

Q2. Cycle Detection in a Singly Linked List

Determine if a given singly linked list of integers forms a cycle or not.

A cycle in a linked list occurs when a node's next points back to a previous node in the list. T...read more

Ans.

Detect if a singly linked list forms a cycle by checking if a node's next points back to a previous node.

  • Traverse the linked list using two pointers, one moving one step at a time and the other moving two steps at a time.

  • If the two pointers meet at any point, there is a cycle in the linked list.

  • If one of the pointers reaches the end of the list (null), there is no cycle.

Add your answer

Q3. N Queens Problem

Given an integer N, find all possible placements of N queens on an N x N chessboard such that no two queens threaten each other.

Explanation:

A queen can attack another queen if they are in the...read more

Ans.

The N Queens Problem involves finding all possible placements of N queens on an N x N chessboard where no two queens threaten each other.

  • Use backtracking algorithm to explore all possible configurations.

  • Keep track of rows, columns, and diagonals to ensure queens do not attack each other.

  • Generate and print valid configurations where queens are placed safely.

  • Consider constraints and time limit for efficient solution.

  • Example: For N=4, valid configurations are: 0010100000101000 a...read more

Add your answer

Q4. Balanced Parentheses Combinations

Given an integer N representing the number of pairs of parentheses, find all the possible combinations of balanced parentheses using the given number of pairs.

Explanation:

Con...read more

Ans.

Generate all possible combinations of balanced parentheses for a given number of pairs.

  • Use recursion to generate all possible combinations of balanced parentheses.

  • Keep track of the number of open and close parentheses used in each combination.

  • Return the valid combinations as an array of strings.

Add your answer
Discover P-Mech Consultant interview dos and don'ts from real experiences

Q5. Ninja and Substrings Problem Statement

Ninja has to determine all the distinct substrings of size two that can be formed from a given string 'STR' comprising only lowercase alphabetic characters. These substrin...read more

Ans.

Find all unique contiguous substrings of size two from a given string.

  • Iterate through the string and extract substrings of size two

  • Use a set to store unique substrings

  • Return the set as an array of strings

Add your answer

Q6. Launch modes on android

Ans.

Launch modes on Android determine how a new instance of an activity is associated with the current task.

  • Standard: Creates a new instance of the activity in the task's stack

  • SingleTop: If an instance of the activity already exists at the top of the stack, it will not be recreated

  • SingleTask: Activity is always at the root of the task and no other activities can be on top of it

  • SingleInstance: Similar to SingleTask, but the activity is launched in a new task

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at P-Mech Consultant

based on 2 interviews
Interview experience
4.0
Good
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

3.8
 • 76 Interview Questions
3.7
 • 30 Interview Questions
3.1
 • 19 Interview Questions
3.7
 • 17 Interview Questions
3.9
 • 13 Interview Questions
3.6
 • 12 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

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