Software Developer

filter-iconFilter interviews by

1000+ Software Developer Interview Questions and Answers for Freshers

Updated 28 Feb 2025

Popular Companies

search-icon

Q51. Strings of Numbers Problem Statement

You are given two integers 'N' and 'K'. Consider a set 'X' of all possible strings of 'N' number of digits where all strings only contain digits ranging from 0 to 'K' inclus...read more

Ans.

The task is to find a string of minimal length that includes every possible string of N digits with digits ranging from 0 to K as substrings.

  • Generate all possible strings of N digits with digits from 0 to K

  • Concatenate these strings in a way that all are substrings of the final string

  • Return 1 if the final string contains all possible strings, else return 0

Q52. Delete Alternate Nodes from a Singly Linked List

Given a Singly Linked List of integers, remove all the alternate nodes from the list.

Input:

The first and the only line of input will contain the elements of th...read more
Ans.

Remove alternate nodes from a singly linked list of integers.

  • Traverse the linked list and skip every alternate node while updating the next pointers.

  • Make sure to handle cases where there are less than 3 nodes in the list.

  • Update the next pointers accordingly to remove alternate nodes.

  • Example: Input: 10 20 30 40 50 60 -1, Output: 10 30 50

Q53. Fruits and Baskets Problem Statement

You are given 'n' fruit trees planted along a road, numbered from 0 to n-1. Each tree bears a fruit type represented by an uppercase English alphabet. A Ninja walking along ...read more

Ans.

The problem is to find the maximum number of fruits the Ninja can put in both baskets after satisfying given conditions.

  • The Ninja can start at any tree and end at any tree, but cannot skip a tree.

  • He can pick one fruit from each tree until he cannot, i.e., when he has to pick a fruit of the third type.

  • The restriction is that each basket can have only one type of fruit.

  • We need to find the maximum number of fruits that can be put in both baskets.

Q54. Problem: Sort an Array of 0s, 1s, and 2s

Given an array/list ARR consisting of integers where each element is either 0, 1, or 2, your task is to sort this array in increasing order.

Input:

The input starts with...read more
Ans.

The task is to sort an array of 0s, 1s, and 2s in increasing order.

  • Use a three-pointer approach to partition the array into three sections: 0s, 1s, and 2s.

  • Initialize three pointers: low, mid, and high. low points to the start of the array, mid points to the current element being processed, and high points to the end of the array.

  • While mid <= high, perform the following checks: if arr[mid] == 0, swap arr[low] and arr[mid], increment low and mid. If arr[mid] == 1, increment mid...read more

Are these interview questions helpful?

Q55. 0/1 Knapsack Problem Statement

A thief is planning to rob a store and can carry a maximum weight of 'W' in his knapsack. The store contains 'N' items where the ith item has a weight of 'wi' and a value of 'vi'....read more

Ans.

Yes, the 0/1 Knapsack problem can be solved using dynamic programming with a space complexity of not more than O(W).

  • Use a 1D array to store the maximum value that can be stolen for each weight from 0 to W.

  • Iterate through each item and update the array based on whether including the item would increase the total value.

  • The final value in the array at index W will be the maximum value that can be stolen.

Q56. Dice Throws Problem Statement

You are given D dice, each having F faces numbered from 1 to F. The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers e...read more

Ans.

The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers equals the given 'target' sum.

  • Use dynamic programming to solve the problem efficiently.

  • Create a 2D array to store the number of ways to achieve each sum with the given number of dice.

  • Iterate through the dice and faces to calculate the number of ways to reach each sum.

  • Return the result modulo 10^9 + 7.

  • Optimize the solution to use no more than O(S) extra space by u...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q57. First Unique Character in a Stream Problem Statement

Given a string A consisting of lowercase English letters, determine the first non-repeating character at each point in the stream of characters.

Example:

Inp...read more
Ans.

Given a string of lowercase English letters, find the first non-repeating character at each point in the stream.

  • Create a hashmap to store the frequency of each character as it appears in the stream.

  • Iterate through the stream and check the frequency of each character to find the first non-repeating character.

  • Output the first non-repeating character at each point in the stream.

Q58. Multiples of 2 and 3 Problem Statement

Ninja is engaged in a task involving divisors. He is given 'N' numbers, and his objective is to compute the sum of all numbers which are divisible by either 2 or 3.

Exampl...read more

Ans.

Find the sum of numbers divisible by 2 or 3 from a given list of numbers.

  • Iterate through the list of numbers and check if each number is divisible by 2 or 3.

  • If a number is divisible by 2 or 3, add it to the sum.

  • Return the final sum as the output.

Software Developer Jobs

Software Developer 8-13 years
Siemens Healthcare
4.3
Bangalore / Bengaluru
Software Developer- Java 2-4 years
Ericsson India Global Services Pvt. Ltd.
4.1
Chennai
Software Developer 3-9 years
Siemens Healthcare
4.3
Bangalore / Bengaluru

Q59. String Compression Problem Statement

Implement a program that performs basic string compression. When a character is consecutively repeated more than once, replace the consecutive duplicates with the count of r...read more

Ans.

Implement a program to compress a string by replacing consecutive duplicates with the count of repetitions.

  • Iterate through the string and keep track of consecutive characters and their counts.

  • Replace consecutive duplicates with the count of repetitions.

  • Ensure the count of repetitions is ≤ 9.

  • Return the compressed string.

Frequently asked in,

Q60. Count Pairs with Difference K

Given an array of integers and an integer K, determine and print the count of all pairs in the array that have an absolute difference of K.

Input:
The first line of the input conta...read more
Ans.

Count pairs in an array with a specific absolute difference.

  • Iterate through the array and for each element, check if the element + K or element - K exists in the array.

  • Use a hash set to store elements for constant time lookups.

  • Keep track of the count of valid pairs found.

Q61. Sort 0 and 1 Problem Statement

Given an integer array ARR of size N containing only integers 0 and 1, implement a function to sort this array. The solution should scan the array only once without using any addi...read more

Ans.

Sort an array of 0s and 1s in linear time without using additional arrays.

  • Iterate through the array and maintain two pointers, one for 0s and one for 1s.

  • Swap elements at the two pointers based on the current element being 0 or 1.

  • Continue this process until the entire array is sorted in place.

Q62. Count Ways to Climb Stairs Problem

Given a staircase with a certain number of steps, you start at the 0th step, and your goal is to reach the Nth step. At every step, you have the option to move either one step...read more

Ans.

Count the number of distinct ways to climb a staircase with a certain number of steps using either one or two steps at a time.

  • Use dynamic programming to solve this problem efficiently.

  • Keep track of the number of ways to reach each step by considering the number of ways to reach the previous two steps.

  • Return the result modulo 10^9+7 to handle large outputs.

  • Example: For N=4, the distinct ways to climb are {(0,1,2,3,4)}, {(0,1,2,4)}, {(0,2,3,4)}, {(0,1,3,4)}, and {(0,2,4)} total...read more

Q63. Kevin and His Cards Problem Statement

Kevin has two packs of cards. The first pack contains N cards, and the second contains M cards. Each card has an integer written on it. Determine two results: the total num...read more

Ans.

Find total distinct card types and common card types between two packs of cards.

  • Create a set to store distinct card types when combining both packs.

  • Iterate through each pack and add card types to the set.

  • Find the intersection of card types between the two packs to get common card types.

Q64. Maximum Sum of Non-Adjacent Elements

Given an array/list of ‘N’ integers, your task is to return the maximum sum of the subsequence where no two elements are adjacent in the given array/list.

Example:

Input:
T ...read more
Ans.

Find the maximum sum of non-adjacent elements in an array.

  • Use dynamic programming to keep track of the maximum sum at each index, considering whether to include the current element or skip it.

  • At each index, the maximum sum is either the sum of the current element and the element two positions back, or the sum at the previous index.

  • Iterate through the array and update the maximum sum at each index accordingly.

  • Return the maximum sum obtained at the last index as the final resul...read more

Q65. N-th Term Of Geometric Progression

Find the N-th term of a Geometric Progression (GP) series given the first term A, the common ratio R, and the term position N.

Explanation:

The general form of a GP series is ...read more

Ans.

Calculate the N-th term of a Geometric Progression series given the first term, common ratio, and term position.

  • Use the formula A * R^(N-1) to find the N-th term of the GP series.

  • Remember to return the result modulo 10^9 + 7 as the term can be very large.

  • Handle multiple test cases efficiently by iterating through each case.

Q66. Non-Decreasing Array Problem Statement

Given an integer array ARR of size N, determine if it can be transformed into a non-decreasing array by modifying at most one element.

An array is defined as non-decreasin...read more

Ans.

Determine if an array can be transformed into a non-decreasing array by modifying at most one element.

  • Iterate through the array and check if there are more than one decreasing elements.

  • If there is only one decreasing element, check if modifying it can make the array non-decreasing.

  • Return true if the array can be made non-decreasing by modifying at most one element, otherwise false.

Q67. Trapping Rain Water in 2-D Elevation Map

You're given an M * N matrix where each value represents the height of that cell on a 2-D elevation map. Your task is to determine the total volume of water that can be ...read more

Ans.

Calculate the total volume of water that can be trapped in a 2-D elevation map after rain.

  • Iterate over the matrix and find the maximum height on the borders.

  • Calculate the water trapped at each cell by finding the difference between the cell's height and the minimum of its neighboring maximum heights.

  • Sum up the trapped water for all cells to get the total volume of water trapped.

Q68. Alternate Print Problem Statement

Given two strings A and B, your task is to print these two strings in an alternating sequence by indices. That is, the first character of 'A', the first character of 'B', follo...read more

Ans.

The task is to print two strings in an alternating sequence by indices.

  • Iterate through both strings simultaneously and append characters alternately

  • Handle the case where one string is longer than the other

  • Use two pointers to keep track of the current index in each string

Q69. Idempotent Matrix Verification

Determine if a given N * N matrix is an idempotent matrix. A matrix is considered idempotent if it satisfies the following condition:

M * M = M

Input:

The first line contains a si...read more
Ans.

Check if a given matrix is idempotent by verifying if M * M = M.

  • Iterate through the matrix and multiply it with itself to check if it equals the original matrix.

  • If the condition M * M = M is satisfied, then the matrix is idempotent.

  • If the condition is not satisfied, then the matrix is not idempotent.

Q70. Palindromic Substrings Problem Statement

You are given a string 'STR'. Your task is to determine the total number of palindromic substrings present in 'STR'.

Example:

Input:
"abbc"
Output:
5
Explanation:

The pa...read more

Ans.

Count the total number of palindromic substrings in a given string.

  • Iterate through each character in the string and expand around it to find palindromic substrings.

  • Use dynamic programming to store the results of subproblems to avoid redundant calculations.

  • Consider both odd and even length palindromes while counting.

  • Example: For input 'abbc', the palindromic substrings are ['a', 'b', 'b', 'c', 'bb'], totaling 5.

Q71. Sum of Minimum and Maximum Elements of All Subarrays of Size K

You are provided with an array containing N integers along with an integer K. Your task is to compute the total sum of the minimum and maximum elem...read more

Ans.

Calculate the sum of minimum and maximum elements of all subarrays of size K in an array.

  • Iterate through the array and maintain a deque to store the indices of elements in the current window of size K.

  • Keep track of the minimum and maximum elements in the current window using the deque.

  • Calculate the sum of minimum and maximum elements for each subarray of size K and return the total sum.

Q72. Find the Duplicate Number Problem Statement

Given an integer array 'ARR' of size 'N' containing numbers from 0 to (N - 2). Each number appears at least once, and there is one number that appears twice. Your tas...read more

Ans.

Find the duplicate number in an array of integers from 0 to N-2.

  • Iterate through the array and keep track of the frequency of each number using a hashmap.

  • Return the number with a frequency greater than 1 as the duplicate number.

  • Alternatively, use Floyd's Tortoise and Hare algorithm to find the duplicate number in O(N) time and O(1) space.

Q73. Find the Longest Palindromic Substring

Given a string ‘S’ composed of lowercase English letters, your task is to identify the longest palindromic substring within ‘S’.

If there are multiple longest palindromic ...read more

Ans.

Find the longest palindromic substring in a given string, returning the rightmost one if multiple substrings are of the same length.

  • Iterate through each character in the string and expand around it to find palindromic substrings

  • Keep track of the longest palindromic substring found so far

  • Return the rightmost longest palindromic substring

Q74. Fourth Largest Element in the Array

Given an array consisting of integers, your task is to determine the fourth largest element in the array. If the array does not contain at least four distinct elements, retur...read more

Ans.

Find the fourth largest element in an array, return -2147483648 if not enough distinct elements.

  • Sort the array in descending order

  • Return the fourth element if it exists, else return -2147483648

Q75. Longest Palindromic Subsequence Problem Statement

Given a string A consisting of lowercase English letters, determine the length of the longest palindromic subsequence within A.

Explanation:

  • A subsequence is d...read more
Ans.

The task is to find the length of the longest palindromic subsequence in a given string.

  • A subsequence is a sequence generated from a string after deleting some or no characters of the string without changing the order of the remaining string characters.

  • A string is said to be palindrome if the reverse of the string is the same as the actual string.

  • Find the longest palindromic subsequence by considering all possible subsequences of the given string.

  • Use dynamic programming to ef...read more

Q76. Longest Subarray with Zero Sum

Ninja enjoys working with numbers, and as a birthday challenge, his friend provides him with an array consisting of both positive and negative integers. Ninja is curious to identi...read more

Ans.

Find the length of the longest subarray with zero sum in an array of integers.

  • Iterate through the array and keep track of the running sum using a hashmap.

  • If the running sum is seen before, the subarray between the current index and the previous index with the same sum is a subarray with zero sum.

  • Update the length of the longest subarray with zero sum as you iterate through the array.

  • Example: For arr1 = [1, -1, 3, 2, -2, -3, 3], the longest subarray with zero sum is [3, 2, -2,...read more

Q77. Meeting Rescheduling Challenge

Ninja is tasked with organizing a meeting in an office that starts at time ‘0’ and ends at time ‘LAST’. There are ‘N’ presentations scheduled with given start and end times. The p...read more

Ans.

Reschedule at most K presentations to maximize longest gap without overlap.

  • Iterate through presentations and calculate the gap between each pair of presentations

  • Sort the presentations by their start times and keep track of the longest gap

  • Reschedule at most K presentations to maximize the longest gap without overlap

Q78. Palindrome String Validation

Determine if a given string 'S' is a palindrome, considering only alphanumeric characters and ignoring spaces and symbols.

Note:
The string 'S' should be evaluated in a case-insensi...read more
Ans.

The task is to check whether a given string is a palindrome or not, considering only alphabets and numbers and ignoring symbols and whitespaces.

  • Convert the string to lowercase and remove all symbols and whitespaces.

  • Reverse the modified string and compare it with the original string.

  • If they are equal, then the string is a palindrome.

  • If not, then the string is not a palindrome.

Q79. 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 array of 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.

  • Maintain left pointer for 0s, right pointer for 2s, and current pointer for traversal.

  • Example: If current element is 0, swap it with element at left pointer and increment both pointers.

Q80. Delete a Node from a Linked List

You are provided with a linked list of integers. Your task is to implement a function that deletes a node located at a specified position 'POS'.

Input:

The first line contains a...read more
Ans.

Implement a function to delete a node from a linked list at a specified position.

  • Traverse the linked list to find the node at the specified position.

  • Update the pointers of the previous and next nodes to skip the node to be deleted.

  • Handle edge cases such as deleting the head or tail of the linked list.

  • Ensure to free the memory of the deleted node to avoid memory leaks.

Q81. K-th Permutation Sequence Problem Statement

Given two integers N and K, your task is to find the K-th permutation sequence of numbers from 1 to N. The K-th permutation is the K-th permutation in the set of all ...read more

Ans.

Find the K-th permutation sequence of numbers from 1 to N.

  • Generate all permutations of numbers from 1 to N using backtracking or next_permutation function.

  • Sort the permutations in lexicographical order.

  • Return the K-th permutation from the sorted list.

Q82. Shopping Spree Problem Statement

Preeti plans to shop for her father's birthday at a store with unlimited quantities of N different items. She has a budget that allows her to buy a maximum of K items. Help Pree...read more

Ans.

Calculate the number of ways Preeti can purchase items within budget, with at least one item quantity differing.

  • Use dynamic programming to calculate the number of ways to purchase items within budget.

  • Consider different scenarios where Preeti buys different quantities of each item.

  • Return the result modulo 10^9 + 7 to handle large answers.

Q83. Sum of Squares of First N Natural Numbers Problem Statement

You are tasked with finding the sum of squares of the first N natural numbers for given test cases.

Input:

The first line contains an integer 'T', the...read more
Ans.

Calculate the sum of squares of the first N natural numbers for given test cases.

  • Read the number of test cases 'T'

  • For each test case, read the value of 'N'

  • Calculate the sum of squares of the first 'N' natural numbers

  • Output the result for each test case

Q84. Tiling Problem Statement

Given a board with 2 rows and N columns, and an infinite supply of 2x1 tiles, determine the number of distinct ways to completely cover the board using these tiles.

You can place each t...read more

Ans.

The problem involves finding the number of ways to tile a 2xN board using 2x1 tiles.

  • Use dynamic programming to solve this problem efficiently.

  • Define a recursive function to calculate the number of ways to tile the board.

  • Consider both horizontal and vertical placements of tiles.

  • Implement the function to handle large values of N using modulo arithmetic.

  • Example: For N = 4, the number of ways to tile the board is 5.

Q85. Binary Tree Right View Problem Statement

Given a binary tree of integers, your task is to print the right view of it. The right view represents a set of nodes visible when the tree is viewed from the right side...read more

Ans.

The task is to print the right view of a binary tree, representing nodes visible from the right side in top-to-bottom order.

  • Traverse the tree level by level and keep track of the rightmost node at each level

  • Print the rightmost node of each level to get the right view of the tree

  • Use a queue for level order traversal and a map to store the rightmost nodes

Q86. Cache Operations Problem

You are provided with a cache that can hold a maximum of 'N' elements. Initially, this cache is empty. There are two main operations you can perform on this cache:

Explanation:

  • Operati...read more
Ans.

Implement a cache with insert, update, and retrieve operations, returning results of retrieve operations in order.

  • Create a cache data structure with specified size 'N'.

  • Implement insert and update operations based on the given criteria.

  • For retrieve operation, return the value associated with the 'U_ID' if present, else return -1.

  • Handle cases where the cache is full and least frequently used items need to be removed.

  • Return the results of all retrieve operations in the order the...read more

Q87. Count Set Bits Problem Statement

Given a positive integer N, compute the total number of '1's in the binary representation of all numbers from 1 to N. Return this count modulo 1e9+7 because the result can be ve...read more

Ans.

The task is to count the total number of '1' in the binary representation of all numbers from 1 to N.

  • Convert each number from 1 to N into its binary representation

  • Count the number of '1' bits in each binary representation

  • Sum up the counts of '1' bits for all numbers

  • Return the sum modulo 1e9+7

Q88. Help Bob Out! - Validating IFSC Code

Bob has just turned 18 and opened a bank account. Being inexperienced with banking, Bob needs your help to validate whether an IFSC code provided by his bank is valid.

The v...read more

Ans.

Validate IFSC code based on given rules and return True or False for each test case.

  • Check if the code is 11 characters long.

  • Verify the first four characters are uppercase alphabets.

  • Ensure the fifth character is '0'.

  • Validate that the last six characters are alphanumeric.

Q89. Meeting Rooms Allocation Problem Statement

Stark Industry is planning to organize meetings for various departments in preparation for Stark Expo. Due to limited rooms in Stark Tower, the goal is to allocate mee...read more

Ans.

Determine the minimum number of conference rooms needed to schedule meetings without overlap.

  • Sort the meetings by start time.

  • Iterate through the meetings and keep track of the rooms in use.

  • If a meeting starts after another ends, it can reuse the same room.

  • If a meeting starts before another ends, a new room is needed.

  • Return the maximum number of rooms in use at any point.

Q90. Ninja and Candies Problem

Ninja, a boy from Ninjaland, receives 1 coin every morning from his mother. He wants to purchase exactly 'N' candies. Each candy usually costs 2 coins, but it is available for 1 coin i...read more

Ans.

Calculate the earliest day on which Ninja can buy all candies with special offers.

  • Iterate through each day and check if any special offer is available for candies Ninja wants to buy

  • Keep track of the minimum day on which Ninja can buy all candies

  • Consider both regular price and sale price of candies

Q91. Occurrence of Each Word: Problem Statement

You are given a string S consisting of several words. Your task is to count the number of times each word appears in string S. A word is defined as a sequence of one o...read more

Ans.

Count the occurrence of each word in a given string.

  • Split the string into words using spaces as delimiters.

  • Use a hashmap to store the count of each word.

  • Iterate through the words and update the count in the hashmap.

  • Output each unique word with its occurrence count.

Q92. Rotational Equivalence of Strings Problem Statement

Given two strings 'P' and 'Q' of equal length, determine if string 'P' can be transformed into string 'Q' by cyclically rotating it to the right any number of...read more

Ans.

The task is to check if one string can be converted into another string by cyclically rotating it to the right any number of times.

  • Iterate through each character of the first string and check if it matches the corresponding character in the second string after a certain number of cyclic rotations.

  • If all characters match for any number of cyclic rotations, then the first string can be converted into the second string.

  • Use modulo arithmetic to handle cyclic rotations efficiently...read more

Q93. Shuffle Two Strings Problem Statement

You are provided with three strings A, B, and C. The task is to determine if C is formed by interleaving A and B. C is considered an interleaving of A and B if:

  • The length...read more
Ans.

Check if a string is formed by interleaving two other strings.

  • Iterate through characters of A, B, and C simultaneously to check if C is formed by interleaving A and B.

  • Use dynamic programming to efficiently solve the problem.

  • Handle edge cases like empty strings or unequal lengths of A, B, and C.

  • Example: A = 'aab', B = 'abc', C = 'aaabbc' should return True.

Q94. Snake and Ladder Problem Statement

Given a 'Snake and Ladder' board with N rows and N columns, where positions are numbered from 1 to (N*N) starting from the bottom left, alternating direction each row, find th...read more

Ans.

Find the minimum number of dice throws required to reach the last cell on a 'Snake and Ladder' board.

  • Start from the bottom left cell and move according to dice outcomes (1-6).

  • Utilize snakes and ladders to reach the last cell faster.

  • Keep track of the minimum number of throws required to reach the last cell.

  • If unreachable, return -1 as output.

Q95. Stock Trading Maximum Profit Problem

Given the stock prices for 'N' days, your goal is to determine the maximum profit that can be achieved. You can buy and sell the stocks any number of times but can only hold...read more

Ans.

The goal is to determine the maximum profit that can be achieved by buying and selling stocks on different days.

  • Iterate through the stock prices and buy on days when the price is lower than the next day, and sell on days when the price is higher than the next day.

  • Calculate the profit by summing up the differences between buying and selling prices.

  • Repeat the process for each test case and output the maximum profit achieved.

  • Example: For prices [7, 1, 5, 3, 6, 4], buy on day 2 a...read more

Q96. String Transformation Problem Statement

Given a string str of length N, perform a series of operations to create a new string:

  1. Select the smallest character from the first 'K' characters of the string, remove ...read more
Ans.

The problem involves selecting the smallest character from the first 'K' characters of a string and appending it to a new string until the original string is empty.

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

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

  • If fewer than 'K' characters remain, sort and append them in order.

  • Repeat the process until the original string is empty.

Q97. Find the Second Largest Element

Given an array or list of integers 'ARR', identify the second largest element in 'ARR'.

If a second largest element does not exist, return -1.

Example:

Input:
ARR = [2, 4, 5, 6, ...read more
Ans.

The task is to find the second largest element in an array of integers.

  • Iterate through the array and keep track of the largest and second largest elements.

  • Initialize the largest and second largest variables with the first two elements of the array.

  • Compare each element with the largest and second largest variables and update them accordingly.

  • Return the second largest element at the end.

Q98. Maximum Vehicle Registrations Problem

Bob, the mayor of a state, seeks to determine the maximum number of vehicles that can be uniquely registered. Each vehicle's registration number is structured as follows: S...read more

Ans.

Calculate the maximum number of unique vehicle registrations based on given constraints.

  • Parse input for number of test cases, district count, letter ranges, and digit ranges.

  • Calculate the total number of unique registrations based on the given constraints.

  • Output the maximum number of unique vehicle registrations for each test case.

Q99. Sort Array by Reversing a Subarray

You are given an array of 'N' distinct integers, 'ARR'. Determine if it is possible to sort this array by selecting a continuous subarray and reversing it. Return 'true' if so...read more

Ans.

The question asks whether it is possible to sort an array by choosing a continuous subarray and reversing it.

  • Check if the array is already sorted. If yes, return true.

  • Find the first and last elements of the subarray that needs to be reversed.

  • Check if the subarray is in non-decreasing order. If yes, return true.

  • Check if the elements after the subarray are in non-increasing order. If yes, return true.

  • Otherwise, return false.

Q100. Array Intersection Problem Statement

Given two integer arrays/ lists ARR1 and ARR2 of sizes N and M respectively, you are required to determine their intersection. An intersection is defined as the set of commo...read more

Ans.

Find the intersection of two integer arrays/lists in the order they appear in the first array/list.

  • Iterate through the elements of the first array/list and check if they exist in the second array/list.

  • Use a hash set to store elements of the first array/list for efficient lookups.

  • Print the common elements in the order they appear in the first array/list.

Previous
1
2
3
4
5
6
7
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.4k Interviews
3.8
 • 8.2k Interviews
3.6
 • 7.6k Interviews
3.7
 • 5.6k Interviews
3.7
 • 5.6k Interviews
4.1
 • 5k Interviews
3.7
 • 4.8k Interviews
3.5
 • 1.3k Interviews
3.7
 • 514 Interviews
4.3
 • 505 Interviews
View all

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

Recently Viewed
SALARIES
DXC Technology
SALARIES
TELUS Digital
SALARIES
Hewlett Packard Enterprise
DESIGNATION
DESIGNATION
INTERVIEWS
Temenos
10 top interview questions
SALARIES
ThoughtWorks
SALARIES
Genpact
SALARIES
NTT Data
SALARIES
Hewlett Packard Enterprise
Software Developer Interview Questions
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
65 L+

Reviews

4 L+

Interviews

4 Cr+

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