Add office photos
Engaged Employer

Paytm

3.3
based on 7.4k Reviews
Video summary
Filter interviews by

70+ Automatic Data Processing (ADP) Interview Questions and Answers

Updated 19 Nov 2024
Popular Designations

Q1. Puzzle : 100 people are standing in a circle .each one is allowed to shoot a person infront of him and he hands the gun to the next to next person for e.g 1st person kills 2nd and hands gun to 3rd .This continu...

read more
Ans.

A puzzle where 100 people shoot the person in front of them until only one person remains.

  • Each person shoots the person in front of them and hands the gun to the next to next person.

  • This continues until only one person remains.

  • The last person standing is the one who was not shot by anyone.

View 18 more answers

Q2. Generate Binary Strings with No Consecutive 1s

Given an integer K, your task is to produce all binary strings of length 'K' that do not contain consecutive '1's.

Input:

The input begins with an integer 'T', the...read more
Ans.

Generate all binary strings of length 'K' with no consecutive '1's in lexicographically increasing order.

  • Use backtracking to generate all possible binary strings without consecutive '1's.

  • Start with an empty string and recursively add '0' or '1' based on the condition.

  • Keep track of the current string and its length to ensure no consecutive '1's are added.

  • Sort the generated strings in lexicographically increasing order before outputting.

Add your answer

Q3. Minimum Number of Coins Problem

Dora, on her visit to India, decides to enjoy Indian cuisine where payments are accepted only in specific denominations. Your task is to help Dora obtain the minimum number of co...read more

Ans.

Find the minimum number of coins needed to make up a given amount using specific denominations.

  • Iterate through the available denominations in descending order

  • For each denomination, calculate the maximum number of coins that can be used

  • Subtract the total value of coins used from the amount until amount becomes 0

Add your answer

Q4. Longest Consecutive Sequence Problem Statement

You are provided with an unsorted array/list ARR of N integers. Your task is to determine the length of the longest consecutive sequence present in the array.

Expl...read more

Ans.

The task is to find the length of the longest consecutive sequence in an unsorted array of integers.

  • Iterate through the array and store all elements in a set for constant time lookup.

  • For each element, check if it is the start of a sequence by looking for element-1 in the set.

  • If it is the start, keep incrementing the count until the next element is not found in the set.

View 1 answer
Discover Automatic Data Processing (ADP) interview dos and don'ts from real experiences

Q5. SpecialStack Design Problem

Design a stack that efficiently supports the getMin() operation in O(1) time with O(1) extra space. This stack should include the following operations: push(), pop(), top(), isEmpty(...read more

Ans.

Design a stack that supports getMin() operation in O(1) time with O(1) extra space using inbuilt stack data structure.

  • Use two stacks - one to store the actual data and another to store the minimum value at each level.

  • When pushing a new element, check if it is smaller than the current minimum and update the minimum stack accordingly.

  • When popping an element, also pop the top element from the minimum stack if it matches the popped element.

  • For getMin() operation, simply return th...read more

Add your answer

Q6. Subsequence Determination Problem

Your task is to verify if the given string STR1 is a subsequence of the string STR2. A subsequence means characters from STR2 are retained in their original order but some (or ...read more

Ans.

Verify if a string is a subsequence of another string by checking if characters are retained in order.

  • Iterate through both strings simultaneously, checking if characters match in order.

  • If a character in STR1 matches a character in STR2, move to the next character in STR2.

  • If all characters in STR1 are found in STR2 in order, return True; otherwise, return False.

Add your answer
Are these interview questions helpful?

Q7. Segregate Even and Odd Nodes in a Linked List

You are given the head node of a singly linked list head. Your task is to modify the linked list so that all the even-valued nodes appear before all the odd-valued ...read more

Ans.

Reorder a singly linked list so that all even-valued nodes appear before odd-valued nodes while preserving the original order.

  • Create two separate linked lists for even and odd nodes

  • Traverse the original list and move nodes to respective even or odd lists

  • Merge the even and odd lists while maintaining the original order

Add your answer

Q8. Ninja Technique Problem Statement

Implement a function that determines whether a given numeric string contains any substring whose integer value equals the product of two consecutive integers. The function shou...read more

Ans.

Implement a function to determine if a numeric string contains a substring whose value equals the product of two consecutive integers.

  • Iterate through all substrings of the input string and check if their integer value equals the product of two consecutive integers.

  • Use nested loops to generate all possible substrings efficiently.

  • Check if the product of two consecutive integers matches the integer value of the substring.

  • Return 'True' if any such substring is found, otherwise re...read more

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Find Nodes at a Specific Distance from Target in a Binary Tree

Given a binary tree, a target node within this tree, and an integer K, identify and return all nodes that are exactly K edges away from the target ...read more

Ans.

Find nodes at a specific distance from a target node in a binary tree.

  • Traverse the binary tree to find the target node.

  • Perform a depth-first search to identify nodes at distance K from the target node.

  • Return the values of nodes found at distance K in an array.

Add your answer

Q10. Subtree of Another Tree Problem Statement

Given two binary trees, T and S, determine whether S is a subtree of T. The tree S should have the same structure and node values as a subtree of T.

Explanation:

A subt...read more

Ans.

Given two binary trees T and S, determine if S is a subtree of T with the same structure and node values.

  • Traverse through tree T and check if any subtree matches tree S

  • Use recursion to compare nodes of both trees

  • Handle edge cases like null nodes and empty trees

Add your answer

Q11. Ways To Make Coin Change

Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more

Ans.

The task is to determine the total number of ways to make change for a specified value using given denominations.

  • Use dynamic programming to keep track of the number of ways to make change for each value up to the target value.

  • Iterate through each denomination and update the number of ways to make change for each value based on the current denomination.

  • Handle base cases such as making change for 0 or using only the smallest denomination.

  • Consider edge cases like having a single...read more

Add your answer

Q12. Minimum Subset Sum Difference Problem

Given an array of non-negative integers, your task is to partition this array into two subsets such that the absolute difference between the sums of the subsets is minimize...read more

Ans.

Given an array, partition it into two subsets to minimize the absolute difference between their sums.

  • Use dynamic programming to calculate all possible subset sums.

  • Iterate through the subset sums to find the minimum absolute difference.

  • Consider all possible partitions of the array elements.

  • Example: For input [1, 6, 11, 5], the minimum absolute difference is 1.

  • Example: For input [1, 2, 3], the minimum absolute difference is 0.

Add your answer

Q13. Min Stack Problem Statement

Design a special stack that supports the following operations in constant time:

  1. Push(num): Insert the given number into the stack.
  2. Pop: Remove and return the top element from the st...read more
Ans.

Design a special stack supporting constant time operations like push, pop, top, and getMin.

  • Implement a stack using an additional stack to keep track of the minimum element.

  • Use two stacks - one to store elements and another to store minimum values.

  • Ensure constant time complexity for all operations by maintaining the minimum value at the top of the min stack.

  • Example: Push(1), Push(2), getMin() should return 1.

Add your answer

Q14. Minimum Falling Path Sum Problem Statement

Given a square array VEC of integers with N rows and N columns, you need to determine the minimum sum of a falling path through this square array. The array has equal ...read more

Ans.

Find the minimum sum of a falling path through a square array by selecting one element from each row with constraints on column selection.

  • Iterate through the array from the second row, updating each element with the minimum sum of the element and its adjacent elements from the previous row.

  • The minimum sum path will end in the last row with the minimum value.

  • Use dynamic programming to efficiently calculate the minimum falling path sum.

  • Example: For input [[5, 10], [25, 15]], th...read more

Add your answer

Q15. String Transformation Problem

Given a string (STR) of length N, you are tasked to create a new string through the following method:

Select the smallest character from the first K characters of STR, remove it fr...read more

Ans.

Given a string and an integer K, create a new string by selecting the smallest character from the first K characters of the input string and repeating the process until the input string is empty.

  • Iterate through the input string, selecting the smallest character from the first K characters each time.

  • Remove the selected character from the input string and append it to the new string.

  • Continue this process until the input string is empty.

  • Return the final new string formed.

Add your answer

Q16. Geometric Progression Subsequences Problem Statement

Given an array of ‘N’ integers, determine the number of subsequences of length 3 that form a geometric progression with a specified common ratio ‘R’.

Explana...read more

Ans.

Count the number of subsequences of length 3 forming a geometric progression with a specified common ratio in an array of integers.

  • Iterate through the array and for each element, check for possible subsequences of length 3 with the given common ratio.

  • Use a hashmap to store the count of possible subsequences for each element as the middle element.

  • Return the total count of subsequences modulo 10^9 + 7.

  • Example: For input [2, 4, 8, 16] and common ratio 2, the only subsequence [2,...read more

Add your answer

Q17. Group Anagrams Problem Statement

Given an array or list of strings called inputStr, your task is to return the strings grouped as anagrams. Each group should contain strings that are anagrams of one another.

An...read more

Ans.

Group anagrams in an array of strings based on their characters.

  • Iterate through each string in the input array/list.

  • For each string, sort the characters alphabetically to create a key for grouping.

  • Use a hashmap to group strings with the same key.

  • Return the grouped anagrams as separate arrays of strings.

Add your answer

Q18. Middle of a Linked List

You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.

If there is an odd number of elements, return the middle ...read more

Ans.

Return the middle element of a singly linked list, or the one farther from the head node if there are even elements.

  • Traverse the linked list with two pointers, one moving twice as fast as the other

  • When the fast pointer reaches the end, the slow pointer will be at the middle

  • Return the element pointed to by the slow pointer

Add your answer

Q19. Distinct Subsets Count

Given an array arr of N integers that may include duplicates, determine the number of subsets of this array containing only distinct elements.

The result should be returned modulo 109 + 7...read more

Ans.

Count the number of distinct-element subsets in an array modulo 10^9+7.

  • Iterate through the array and keep track of distinct elements using a set.

  • Calculate the number of subsets using the formula 2^distinct_count - 1.

  • Return the result modulo 10^9+7 for each test case.

Add your answer

Q20. Sort an Array in Wave Form

You are given an unsorted array ARR. Your task is to sort it so that it forms a wave-like array.

Input:

The first line contains an integer 'T', the number of test cases.
For each test ...read more
Ans.

Sort an array in wave form where each element is greater than or equal to its adjacent elements.

  • Iterate through the array and swap adjacent elements to form a wave pattern.

  • Ensure that the first element is greater than or equal to the second element.

  • There can be multiple valid wave arrays, so any valid wave array is acceptable.

Add your answer

Q21. Reverse a Linked List Problem Statement

You are given a Singly Linked List of integers. Your task is to reverse the Linked List by changing the links between nodes.

Input:

The first line of input contains a sin...read more
Ans.

Reverse a given singly linked list by changing the links between nodes.

  • Iterate through the linked list and reverse the links between nodes

  • Use three pointers to keep track of the current, previous, and next nodes

  • Update the links between nodes to reverse the list

  • Return the head of the reversed linked list

Add your answer

Q22. Anagram Pairs Verification Problem

Your task is to determine if two given strings are anagrams of each other. Two strings are considered anagrams if you can rearrange the letters of one string to form the other...read more

Ans.

Determine if two strings are anagrams of each other by checking if they have the same characters in different order.

  • Create a frequency map of characters for both strings and compare them.

  • Sort both strings and compare if they are equal.

  • Use a hash table to store character counts and check if they are the same for both strings.

Add your answer

Q23. Diagonal Traversal of a Binary Tree

Given a binary tree of integers, find its diagonal traversal. Refer to the example for clarification on diagonal traversal.

Example:

Explanation:
Consider lines at an angle o...read more
Ans.

Diagonal traversal of a binary tree involves printing nodes at 135 degree angle in between lines.

  • Traverse the tree in a diagonal manner, starting from the root node.

  • Maintain a map to store nodes at each diagonal level.

  • Print the nodes at each diagonal level in the order of traversal.

Add your answer

Q24. Replace 0s Problem Statement

You are given a matrix where every element is either a 1 or a 0. The task is to replace 0 with 1 if it is surrounded by 1s. A 0 (or a set of 0s) is considered to be surrounded by 1s...read more

Ans.

Given a matrix of 1s and 0s, replace 0s surrounded by 1s with 1s.

  • Iterate through the matrix and check each 0 surrounded by 1s.

  • If a 0 is surrounded by 1s, replace it with 1.

  • Update the matrix in place without printing or returning it.

Add your answer

Q25. Kth Smallest Element Problem Statement

You are provided with an array of integers ARR of size N and an integer K. Your task is to find and return the K-th smallest value present in the array. All elements in th...read more

Ans.

Find the K-th smallest element in a given array of distinct integers.

  • Sort the array in ascending order.

  • Return the element at index K-1 from the sorted array.

  • Handle edge cases like K being out of bounds or array being empty.

Add your answer

Q26. Distributing Coins in a Binary Tree

You are provided with the root of a binary tree that consists of 'N' nodes. Each node in this tree contains coins, and the total number of coins across all nodes is equal to ...read more

Ans.

Determine the minimum number of moves required to distribute coins in a binary tree so that every node has exactly one coin.

  • Traverse the binary tree in a bottom-up manner to distribute coins efficiently.

  • Keep track of the excess or deficit of coins at each node to calculate the minimum moves required.

  • Transfer coins from nodes with excess coins to nodes with deficits to balance the distribution.

  • Example: For the input ROOT = [2, -1, 0, -1, -1], the output is 1 as one move is nee...read more

Add your answer

Q27. 0-1 Knapsack Problem Statement

A thief is robbing a store and can carry a maximal weight 'W' in his knapsack. There are 'N' items, where the i-th item has a weight 'wi' and value 'vi'. Consider the maximum weig...read more

Ans.

The 0-1 Knapsack Problem involves maximizing the value of items a thief can steal within a weight limit.

  • Use dynamic programming to solve the problem efficiently.

  • Create a 2D array to store the maximum value that can be achieved at each weight limit.

  • Iterate through the items and weights to fill the array with optimal values.

  • Return the maximum value achievable at the given weight limit.

Add your answer
Q28. ...read more

Number In Arithmetic Progression Problem

Given three integers X, C, and Y, where X is the first term of an arithmetic sequence with a common difference of C, determine if Y is part of this arithmetic sequence.

Ans.

Determine if a given number is part of an arithmetic sequence with a specified first term and common difference.

  • Calculate the arithmetic sequence based on the given first term and common difference.

  • Check if the given number is part of the calculated sequence.

  • Return 'True' if the number belongs to the sequence, otherwise return 'False'.

Add your answer

Q29. Detect and Remove Loop in Linked List

For a given singly linked list, identify if a loop exists and remove it, adjusting the linked list in place. Return the modified linked list.

Expected Complexity:

Aim for a...read more

Ans.

Detect and remove loop in a singly linked list in place with O(n) time complexity and O(1) space complexity.

  • Use Floyd's Cycle Detection Algorithm to identify the loop in the linked list.

  • Once the loop is detected, use two pointers to find the start of the loop.

  • Adjust the pointers to remove the loop and return the modified linked list.

Add your answer

Q30. Permutations Problem Statement

Given an array of distinct integers, find all possible permutations of the array.

Explanation:

A permutation is a mathematical way of determining the number of possible arrangemen...read more

Ans.

Find all possible permutations of an array of distinct integers.

  • Use backtracking to generate all possible permutations

  • Swap elements to create different permutations

  • Return the permutations as an array of arrays of integers

Add your answer

Q31. Decode String Problem Statement

Your task is to decode a given encoded string back to its original form.

Explanation:

An encoded string format is [encoded_string], where the 'encoded_string' inside the square b...read more

Ans.

Decode a given encoded string back to its original form by repeating the encoded string 'count' times.

  • Parse the input string to extract the count and the encoded string within the brackets

  • Use recursion to decode the encoded string by repeating it 'count' times

  • Handle nested brackets by recursively decoding the inner strings first

Add your answer

Q32. How will you implement a shuffle function for a playlist of songs

Ans.

Implementing a shuffle function for a playlist of songs

  • Create a new empty playlist

  • Randomly select a song from the original playlist and add it to the new playlist

  • Remove the selected song from the original playlist

  • Repeat until all songs have been added to the new playlist

  • Return the new shuffled playlist

Add your answer

Q33. Running Median Problem

Given a stream of integers, calculate and print the median after each new integer is added to the stream.

Output only the integer part of the median.

Example:

Input:
N = 5 
Stream = [2, 3,...read more
Ans.

Calculate and print the median after each new integer is added to the stream.

  • Use a min heap to store the larger half of the numbers and a max heap to store the smaller half.

  • Keep the two heaps balanced by ensuring the size difference is at most 1.

  • If the total number of elements is odd, the median is the top of the larger heap. If even, average the tops of both heaps.

Add your answer

Q34. How many BSTs are possible with two nodes and three nodes?

Ans.

Number of possible BSTs with 2 and 3 nodes.

  • For 2 nodes, only 2 BSTs are possible.

  • For 3 nodes, 5 BSTs are possible.

  • Number of BSTs can be calculated using Catalan numbers formula.

  • Catalan(2) = 2, Catalan(3) = 5.

Add your answer

Q35. a unsorted array was given and a number x.find out the two elements whose sum is equal to x

Ans.

Find two elements in an unsorted array whose sum is equal to a given number x.

  • Use a hash table to store the difference between x and each element in the array.

  • Iterate through the array and check if the current element is in the hash table.

  • Return the pair of elements that add up to x.

Add your answer

Q36. What is my favourite app and any improvements in it which i want to implement?

Ans.

My favourite app is Spotify. I would like to see improvements in the algorithm for personalized playlists.

  • Improved algorithm for personalized playlists

  • Better integration with social media platforms

  • Option to create collaborative playlists with friends

Add your answer
Q37. Can you explain the implementation of an LRU (Least Recently Used) Cache in a database management system?
Ans.

LRU cache in a database management system stores most recently used data and removes least recently used data when full.

  • LRU cache is implemented using a doubly linked list and a hash map.

  • Each node in the linked list represents a key-value pair.

  • When a key is accessed, it is moved to the front of the linked list.

  • If the cache is full, the least recently used node at the end of the list is removed.

  • Example: If cache size is 3 and keys accessed in order are A, B, C, D, A, then afte...read more

Add your answer

Q38. two arrays of arrival time of trains and departure time of trains were given. find the minimum no of platforms require so that no collision occurs

Ans.

Find minimum no of platforms required to avoid collision between trains based on their arrival and departure times.

  • Sort both arrays in ascending order

  • Initialize platform count and max count to 1

  • Loop through both arrays and compare arrival and departure times

  • If arrival time is less than or equal to departure time, increment platform count

  • Else, decrement platform count

  • Update max count if platform count is greater than max count

  • Return max count

Add your answer

Q39. How many trees are possible with two and three nodes?

Ans.

Answering the question about possible trees with two and three nodes.

  • For two nodes, there is only one possible tree.

  • For three nodes, there are three possible trees.

  • The formula for calculating the number of possible trees with n nodes is (2n-3)!!.

  • The double exclamation mark represents the double factorial function.

  • The double factorial function is defined as n!! = n(n-2)(n-4)...(1 or 2).

Add your answer

Q40. Find the row with max number of vowels in a 2×2 matrix. Given that first element of each row contains a vowel if there are any in the whole row.

Ans.

Find row with max vowels in 2x2 matrix with first element of each row containing a vowel.

  • Iterate through each row and count the number of vowels in it.

  • Keep track of the row with max number of vowels.

  • If first element of a row is a vowel, start counting from that element.

  • Example: [['a', 'b'], ['e', 'i']] should return 2nd row.

Add your answer

Q41. Write a function in javascript to hide text on mouse click

Ans.

Function to hide text on mouse click in JavaScript

  • Create a function that takes an element as input

  • Add an event listener to the element for a mouse click

  • Toggle the element's display property between 'none' and its original value

Add your answer

Q42. What is the problem with arrays?

Ans.

Arrays have fixed size and can lead to memory wastage and performance issues.

  • Arrays have a fixed size and cannot be resized dynamically.

  • Inserting or deleting elements in an array can be time-consuming.

  • Arrays can lead to memory wastage if they are not fully utilized.

  • Arrays can cause performance issues if they are too large and need to be traversed frequently.

  • Arrays can also be prone to buffer overflow attacks.

  • Example: An array of size 10 is created but only 5 elements are used...read more

Add your answer

Q43. What is JVM ? Difference between JVM and compiler

Ans.

JVM stands for Java Virtual Machine. It is an abstract machine that provides a runtime environment for Java programs.

  • JVM is responsible for interpreting the compiled Java code and executing it.

  • It provides platform independence by converting bytecode into machine-specific code.

  • JVM has various components like class loader, bytecode verifier, and execution engine.

  • Compiler converts source code into bytecode, while JVM executes the bytecode.

  • JVM is used not only for Java but also f...read more

Add your answer

Q44. what is indexing? Why it is used?

Ans.

Indexing is the process of creating an index for faster data retrieval. It is used to improve search performance.

  • Indexing creates a data structure that allows for faster searching and sorting of data.

  • It is commonly used in databases to improve query performance.

  • Examples of indexing include B-trees, hash indexes, and bitmap indexes.

  • Without indexing, searching through large amounts of data can be slow and inefficient.

View 1 answer
Q45. What are the conditions for a deadlock to occur?
Ans.

Deadlock occurs when two or more processes are waiting for each other to release resources, resulting in a standstill.

  • Two or more processes must be holding resources and waiting for resources held by other processes

  • Processes cannot proceed because they are stuck in a circular wait

  • Resources cannot be forcibly released by the operating system

  • Examples: Process A holds Resource 1 and waits for Resource 2, while Process B holds Resource 2 and waits for Resource 1

Add your answer

Q46. What are B+ trees?what is the advantage?

Ans.

B+ trees are balanced trees used for indexing and searching large amounts of data.

  • B+ trees are similar to binary search trees but have multiple keys per node.

  • They are commonly used in databases and file systems.

  • B+ trees have a high fanout, reducing the number of disk accesses required for searching.

  • They are also self-balancing, ensuring efficient performance even with large amounts of data.

  • Example: In a database, a B+ tree can be used to index customer records by last name.

Add your answer

Q47. Any feature i would like to add in PayTM app?

Ans.

I would like to add a feature for splitting bills among friends.

  • The feature would allow users to split bills for movies, dinners, etc.

  • Users can select friends from their contact list and split the bill equally or unequally.

  • The app would send a notification to the selected friends to pay their share.

  • The feature would make it easier for users to split expenses and avoid awkward conversations.

  • It would also encourage more usage of the PayTM app for group activities.

Add your answer

Q48. Given an array find the number of conitnuous sequences having equal number of 0's and 1's

Ans.

Count the number of continuous sequences with equal number of 0's and 1's in an array.

  • Iterate through the array and keep track of the count of 0's and 1's encountered so far.

  • Store the difference between the counts in a hash table and increment the count for that difference.

  • If the difference is already present in the hash table, add the count to the existing value.

  • Return the sum of all values in the hash table.

Add your answer

Q49. Can you implement a stack using queue

Ans.

Yes, we can implement a stack using two queues.

  • Push operation: Enqueue the element to the first queue.

  • Pop operation: Dequeue all elements from the first queue and enqueue them to the second queue until the last element. Dequeue and return the last element. Swap the names of the queues.

  • Top operation: Same as pop operation but don't dequeue the last element.

  • Example: Push 1, 2, 3. Queue 1: 1 2 3. Queue 2: empty. Pop operation: Dequeue 1 and 2 from queue 1 and enqueue them to que...read more

Add your answer
Q50. Design a stack that supports the getMin() operation in O(1) time and O(1) extra space.
Ans.

Use two stacks - one to store actual values and one to store minimum values.

  • Use two stacks - one to store actual values and one to store minimum values

  • When pushing a new value, check if it is smaller than the current minimum and push it to the min stack if so

  • When popping a value, check if it is the current minimum and pop from min stack if so

  • getMin() operation can be done by peeking at the top of the min stack

Add your answer

Q51. Modify the given 2×2 matrix in such a way that if a cell contains 0 all the elements of corresponding row and columm becomes 0

Ans.

Modify a 2x2 matrix to replace row and column with 0 if a cell contains 0.

  • Iterate through the matrix and find the cells with 0.

  • Store the row and column index of the cells with 0 in separate arrays.

  • Iterate through the row and column arrays and replace all elements with 0.

  • Return the modified matrix.

Add your answer

Q52. what is memory leak?

Ans.

Memory leak is a situation where a program fails to release memory it no longer needs.

  • Memory leaks can cause a program to consume more and more memory over time, eventually leading to crashes or other issues.

  • Memory leaks can be caused by programming errors such as not freeing memory after it is no longer needed.

  • Tools like valgrind can be used to detect memory leaks in C and C++ programs.

  • Examples of memory leaks include forgetting to free memory allocated with malloc() or new,...read more

Add your answer

Q53. which data structure i like?

Ans.

I prefer hash tables for their constant time lookup and insertion.

  • Hash tables are efficient for storing and retrieving data.

  • They have constant time complexity for both insertion and lookup.

  • They can be implemented using arrays or linked lists.

  • Examples include Python's dictionary and Java's HashMap.

Add your answer

Q54. Number of substrngs which are palindrome

Ans.

Count the number of palindromic substrings in a given string.

  • A substring is a contiguous sequence of characters within a string.

  • A palindrome is a string that reads the same backward as forward.

  • Use dynamic programming to count all palindromic substrings.

  • Time complexity can be reduced to O(n^2) using Manacher's algorithm.

Add your answer

Q55. Check wether a given binary tree is a BST or not

Ans.

To check if a binary tree is a BST, we can perform an in-order traversal and ensure that the elements are in sorted order.

  • Perform an in-order traversal of the binary tree

  • Check if the elements are in sorted order

  • If any element is not in sorted order, then the tree is not a BST

Add your answer

Q56. What is BST ?

Ans.

BST stands for Binary Search Tree, a data structure used for efficient searching and sorting operations.

  • BST is a tree-like data structure where each node has at most two children.

  • The left child of a node contains a value less than the parent node, while the right child contains a value greater than the parent node.

  • BST allows for efficient searching and sorting operations with a time complexity of O(log n).

  • Examples of applications of BST include dictionary implementations and ...read more

Add your answer

Q57. 1. Find the no of rotations in a rotated sorted array.

Ans.

Find the number of rotations in a rotated sorted array.

  • Use binary search to find the minimum element in the array.

  • The number of rotations is equal to the index of the minimum element.

  • If the minimum element is at index 0, then there are no rotations.

  • If the array is not rotated, then the number of rotations is 0.

Add your answer

Q58. Merge sort using Linked list ( psuedo code )

Ans.

Merge sort using linked list is a sorting algorithm that divides the list into smaller sublists, sorts them, and then merges them back together.

  • Create a function to merge two sorted linked lists

  • Divide the linked list into two halves using slow and fast pointers

  • Recursively sort the two halves

  • Merge the sorted halves back together

Add your answer

Q59. Give 5 strengths and weakness of yours

Ans.

Strengths: Problem-solving skills, teamwork, adaptability, attention to detail, communication. Weaknesses: Impatience, public speaking, delegation, perfectionism, time management.

  • Strengths: Problem-solving skills - I enjoy tackling complex issues and finding creative solutions.

  • Teamwork - I work well with others and value collaboration in achieving common goals.

  • Adaptability - I am able to quickly adjust to new situations and environments.

  • Attention to detail - I have a keen eye...read more

Add your answer

Q60. Longest Palindrom in a string in O(n)

Ans.

Find the longest palindrome in a given string in linear time complexity.

  • Use Manacher's algorithm to find the longest palindrome in a string in O(n) time complexity.

  • The algorithm involves preprocessing the string to add special characters to handle even and odd length palindromes.

  • Then, it uses a combination of dynamic programming and symmetry properties to find the longest palindrome.

  • For example, in the string 'babad', the longest palindrome is 'bab'.

Add your answer

Q61. What are internal working of has set

Ans.

HashSet is a collection that stores unique elements by using a hash table.

  • Elements are stored based on their hash code

  • Uses hashCode() and equals() methods to check for duplicates

  • Does not maintain insertion order

  • Allows null values

  • Example: HashSet set = new HashSet<>(); set.add("apple"); set.add("banana");

Add your answer

Q62. ZigZag Traversal of Binary Tree

Ans.

Zigzag traversal of a binary tree involves traversing the tree in a zigzag pattern, alternating between left and right at each level.

  • Use a queue to perform level order traversal of the binary tree.

  • For each level, alternate between adding nodes to the result array from left to right and right to left.

  • Continue this pattern until all levels have been traversed.

Add your answer

Q63. Find the value of pie

Ans.

The value of pie is a mathematical constant approximately equal to 3.14159.

  • Pie is the ratio of the circumference of a circle to its diameter.

  • It is an irrational number, meaning it cannot be expressed as a finite decimal or fraction.

  • Pie is commonly used in geometry and trigonometry calculations.

  • The value of pie is often approximated as 3.14 or 22/7.

Add your answer

Q64. level order traversal with alternate order

Ans.

Level order traversal of a binary tree with alternate order

  • Use a queue to perform level order traversal

  • Alternate the order of nodes at each level

  • Example: For a binary tree with nodes 1, 2, 3, 4, 5, the output could be ['1', '3 2', '4 5']

Add your answer

Q65. What is solid principles

Ans.

SOLID principles are a set of five design principles for writing maintainable and scalable code.

  • S - Single Responsibility Principle

  • O - Open/Closed Principle

  • L - Liskov Substitution Principle

  • I - Interface Segregation Principle

  • D - Dependency Inversion Principle

Add your answer

Q66. how web/internet works?

Ans.

The web/internet is a network of interconnected devices that communicate through standardized protocols to share information.

  • Devices connect to the internet through ISPs

  • Data is transmitted through packets using TCP/IP protocols

  • Web browsers use HTTP/HTTPS protocols to request and receive web pages

  • DNS servers translate domain names to IP addresses

  • Web servers host web pages and respond to requests

  • Search engines use web crawlers to index web pages for search results

Add your answer

Q67. Find the element in rotated sorted array

Ans.

Use binary search to find the pivot point and then search for the target element in the appropriate half of the array.

  • Find the pivot point where the array is rotated

  • Use binary search to search for the target element in the appropriate half of the array

  • Handle cases where the target element is not found

Add your answer

Q68. Difference between hashmap and hashtable

Ans.

HashMap is non-synchronized and allows null values, while Hashtable is synchronized and does not allow null keys or values.

  • HashMap is non-synchronized, meaning it is not thread-safe, while Hashtable is synchronized and thread-safe.

  • HashMap allows null values and one null key, while Hashtable does not allow null keys or values.

  • HashMap is generally preferred for non-thread-safe applications, while Hashtable is used in thread-safe scenarios.

Add your answer

Q69. Difference between mongodb and sql

Ans.

MongoDB is a NoSQL database while SQL is a relational database management system.

  • MongoDB is schema-less, allowing for flexible data models.

  • SQL databases use structured query language for defining and manipulating data.

  • MongoDB is better suited for unstructured or semi-structured data, while SQL is better for structured data.

  • SQL databases are ACID compliant, ensuring data integrity, while MongoDB sacrifices some ACID properties for scalability and performance.

  • MongoDB uses a doc...read more

Add your answer

Q70. Boundary Traversal in tree.

Ans.

Boundary traversal in a tree involves visiting the nodes on the boundary of the tree in a specific order.

  • Start by visiting the root node.

  • Then visit all the left boundary nodes in a top-down manner.

  • Next, visit all the leaf nodes from left to right.

  • Finally, visit all the right boundary nodes in a bottom-up manner.

Add your answer

Q71. kth element in a linked list

Ans.

To find the kth element in a linked list, iterate through the list and return the element at the kth position.

  • Iterate through the linked list while keeping track of the current position

  • Return the element when the current position equals k

  • Handle cases where k is out of bounds or the linked list is empty

Add your answer

Q72. Search in a sorted matrix

Ans.

Search for a target value in a sorted matrix efficiently.

  • Start from the top right corner and move left or down based on comparison with target value

  • Utilize the sorted nature of the matrix to eliminate certain rows or columns

  • Implement binary search for more efficient search in each row or column

Add your answer

Q73. implement Stack using 2 queues

Ans.

Implement a Stack using 2 queues

  • Use two queues to simulate the behavior of a stack

  • Push operation can be implemented by adding elements to one of the queues

  • Pop operation can be implemented by transferring elements between the two queues

Add your answer

Q74. Palindromic string using D P

Ans.

Using dynamic programming to find palindromic strings.

  • Create a 2D array to store if substrings are palindromic.

  • Iterate through the string to fill the array based on palindromic conditions.

  • Use the array to construct the palindromic strings.

Add your answer

Q75. Internal working of hashmap

Ans.

HashMap is a data structure that stores key-value pairs and uses hashing to quickly retrieve values based on keys.

  • HashMap internally uses an array of linked lists to store key-value pairs.

  • When a key-value pair is added, the key is hashed to determine the index in the array where it will be stored.

  • If multiple keys hash to the same index, a collision occurs and the key-value pairs are stored in a linked list at that index.

  • To retrieve a value, the key is hashed again to find the...read more

Add your answer

Q76. detect cycle in linked list

Ans.

Use Floyd's Tortoise and Hare algorithm to detect cycle in a linked list.

  • Initialize two pointers, slow and fast, at the head of the linked list.

  • Move slow pointer by one step and fast pointer by two steps.

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

Add your answer

Q77. LinkedIn List based problems

Ans.

LinkedIn List based problems involve manipulating linked lists to solve various coding challenges.

  • Implement common linked list operations like insertion, deletion, and traversal.

  • Solve problems involving reversing a linked list, detecting cycles, or finding the intersection point of two linked lists.

  • Use techniques like two pointers, recursion, or hash tables to optimize solutions.

Add your answer

Q78. convert BST in range

Ans.

Convert a Binary Search Tree (BST) into a new BST containing only nodes within a given range.

  • Perform inorder traversal of the original BST and only add nodes within the given range to the new BST.

  • Recursively call the function on left and right subtrees while checking the node values against the range.

  • Adjust the pointers of the nodes to form the new BST.

Add your answer

Q79. Rotate a linked List

Ans.

Rotate a linked list by k positions

  • Traverse the linked list to find the length and the last node

  • Connect the last node to the head to make it a circular linked list

  • Traverse again to find the new tail node at position length - k % length

  • Set the new head as the next node of the new tail and update the new tail's next to null

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

Interview Process at Automatic Data Processing (ADP)

based on 40 interviews
4 Interview rounds
Coding Test Round
Technical Round - 1
Technical Round - 2
HR Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Engineer Interview Questions from Similar Companies

3.9
 • 50 Interview Questions
3.2
 • 46 Interview Questions
4.0
 • 41 Interview Questions
3.7
 • 15 Interview Questions
3.9
 • 10 Interview Questions
3.9
 • 10 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