Add office photos
Employer?
Claim Account for FREE

Adobe

3.9
based on 1.1k Reviews
Video summary
Filter interviews by

300+ Affinity Global Advertising Interview Questions and Answers

Updated 18 Feb 2025
Popular Designations

Q1. Morty's Array Challenge

Rick has provided Morty with an array 'Arr' of length 'N' and an integer 'K'. Morty needs to split the array into non-empty sub-arrays to achieve the minimum possible cost, subject to th...read more

Add your answer

Q2. Delete the Middle Node from a Singly Linked List

Given a singly linked list of integers, the task is to remove the middle node from this list.

Input:

The first line of input includes an integer 'T' which denote...read more
Ans.

The task is to delete the middle node of a singly linked list of integers.

  • If the linked list is empty or has only one node, there is no middle node to delete.

  • To delete the middle node, we need to find the middle node and update the pointers of the previous and next nodes.

  • To find the middle node in one traversal, we can use two pointers - a slow pointer and a fast pointer.

  • The slow pointer moves one node at a time, while the fast pointer moves two nodes at a time.

  • When the fast ...read more

Add your answer

Q3. Sub Sort Problem Statement

You are given an integer array ARR. Determine the length of the shortest contiguous subarray which, when sorted in ascending order, results in the entire array being sorted in ascendi...read more

Ans.

The task is to find the length of the shortest contiguous subarray that needs to be sorted in order to sort the entire array.

  • Iterate through the array from left to right and find the first element that is out of order.

  • Iterate through the array from right to left and find the first element that is out of order.

  • Find the minimum and maximum elements within the subarray defined by the above two elements.

  • Expand the subarray to include any additional elements that are out of order ...read more

Add your answer

Q4. Sort Array by Set Bit Count

Given an array of positive integers, your task is to sort the array in decreasing order based on the count of set bits in the binary representation of each integer.

If two numbers ha...read more

Add your answer
Discover Affinity Global Advertising interview dos and don'ts from real experiences

Q5. Problem: Search In Rotated Sorted Array

Given a sorted array that has been rotated clockwise by an unknown amount, you need to answer Q queries. Each query is represented by an integer Q[i], and you must determ...read more

Ans.

This is a problem where a sorted array is rotated and we need to search for given numbers in the array.

  • The array is rotated clockwise by an unknown amount.

  • We need to perform binary search to find the index of the given numbers.

  • If the number is found, return its index. Otherwise, return -1.

  • The time complexity of the solution should be O(logN).

Add your answer

Q6. Quick Sort Problem Statement

You are provided with an array of integers. The task is to sort the array in ascending order using the quick sort algorithm.

Quick sort is a divide-and-conquer algorithm. It involve...read more

Ans.

The question asks to implement quick sort algorithm to sort an array of integers in ascending order.

  • Quick sort is a divide and conquer algorithm

  • Choose a pivot point and partition the array into two parts

  • Recursively sort the left and right parts of the array

  • Implement the quick sort algorithm to sort the given array

Add your answer
Are these interview questions helpful?

Q7. Minimum Cost to Make String Valid

Given a string containing only '{' and '}', determine the minimum cost required to make the string valid. A string is considered valid if for every opening bracket '{', there i...read more

Add your answer

Q8. Swap Adjacent Bit Pairs Problem Statement

Given an integer N, your task is to compute the number that results from swapping each even position bit of N's binary representation with its adjacent odd bit to the r...read more

Ans.

The task is to swap each even bit of an integer with its adjacent bit on the right in its binary representation.

  • Convert the given integer to its binary representation

  • Iterate through the binary representation and swap each even bit with its adjacent bit on the right

  • Convert the modified binary representation back to an integer

  • Print the resulting integer

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

Q9. Reverse Linked List Problem Statement

Given a singly linked list of integers, return the head of the reversed linked list.

Example:

Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Add your answer

Q10. LCA in a Binary Search Tree

You are given a binary search tree (BST) containing N nodes. Additionally, you have references to two nodes, P and Q, within this BST.

Your task is to determine the Lowest Common Anc...read more

Ans.

The task is to find the lowest common ancestor (LCA) of two given nodes in a binary search tree (BST).

  • The LCA is the lowest node that has both given nodes as descendants.

  • In a BST, the left subtree of a node contains only nodes with data less than the node's data, and the right subtree contains only nodes with data greater than the node's data.

  • Start from the root node and compare it with the given nodes. If both nodes are smaller than the current node, move to the left subtree...read more

Add your answer

Q11. Power Calculation Problem Statement

Given a number x and an exponent n, compute xn. Accept x and n as input from the user, and display the result.

Note:

You can assume that 00 = 1.

Input:
Two integers separated...read more
Add your answer

Q12. Merge Two Sorted Linked Lists Problem Statement

You are provided with two sorted linked lists. Your task is to merge them into a single sorted linked list and return the head of the combined linked list.

Input:...read more

Ans.

The task is to merge two sorted linked lists into a single sorted linked list.

  • Create a new linked list to store the merged list

  • Compare the values of the nodes from both lists and add the smaller value to the new list

  • Move the pointer of the list with the smaller value to the next node

  • Repeat the comparison and addition until one of the lists is empty

  • Add the remaining nodes from the non-empty list to the new list

  • Return the head of the new list

Add your answer

Q13. Spiral Matrix Problem Statement

You are given a N x M matrix of integers. Your task is to return the spiral path of the matrix elements.

Input

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

The task is to return the spiral path of a given matrix.

  • Iterate through the matrix in a spiral pattern, starting from the outermost layer and moving towards the center.

  • Keep track of the current row, column, and the boundaries of the remaining unvisited matrix.

  • Print the elements in the spiral path as you traverse the matrix.

Add your answer

Q14. Stack with getMin Operation

Create a stack data structure that supports not only the usual push and pop operations but also getMin(), which retrieves the minimum element, all in O(1) time complexity without usi...read more

Add your answer

Q15. Prime with 3 Factors Problem Statement

You are provided with an array ARR consisting of 'N' positive integers. Your task is to determine if each number in the array ARR has exactly 3 factors.

You need to return...read more

Add your answer

Q16. Validate BST Problem Statement

Given a binary tree with N nodes, determine whether the tree is a Binary Search Tree (BST). If it is a BST, return true; otherwise, return false.

A binary search tree (BST) is a b...read more

Add your answer

Q17. Maximum Non-Adjacent Subsequence Sum

Given an array of integers, determine the maximum sum of a subsequence without choosing adjacent elements in the original array.

Input:

The first line consists of an integer...read more
Add your answer

Q18. Colourful Knapsack Problem Statement

You are given N stones labeled from 1 to N. The i-th stone has the weight W[i]. There are M colors labeled by integers from 1 to M. The i-th stone has the color C[i] which i...read more

Add your answer

Q19. Count Distinct Substrings

You are provided with a string S. Your task is to determine and return the number of distinct substrings, including the empty substring, of this given string. Implement the solution us...read more

Add your answer

Q20. Palindromic Partitioning Problem Statement

Given a string ‘str’, calculate the minimum number of partitions required to ensure every resulting substring is a palindrome.

Input:

The first line contains an intege...read more
Add your answer

Q21. Longest Zero Sum Subarray Problem

Given an array of integers consisting of both positive and negative numbers, find the length of the longest subarray whose sum is zero. This problem will be presented with mult...read more

Add your answer

Q22. Maximum Sum Path in a Binary Tree Problem Statement

You are provided with a binary tree consisting of N nodes where each node has an integer value. The task is to determine the maximum sum achievable by a simpl...read more

Add your answer

Q23. Equilibrium Index Problem Statement

Given an array Arr consisting of N integers, your task is to find the equilibrium index of the array.

An index is considered as an equilibrium index if the sum of elements of...read more

Add your answer

Q24. Minimum Fountains Activation Problem

In this problem, you have a one-dimensional garden of length 'N'. Each position from 0 to 'N' has a fountain that can provide water to the garden up to a certain range. Thus...read more

Add your answer

Q25. Maximum Meetings Problem Statement

Given the schedule of N meetings with their start time Start[i] and end time End[i], you need to determine which meetings can be organized in a single meeting room such that t...read more

Add your answer

Q26. Maximum Sum Problem Statement

You are given an array ARR of N integers. Your task is to perform operations on this array until it becomes empty, and maximize the sum of selected elements. In each operation, sel...read more

Add your answer

Q27. Split Array into 'K' Consecutive Subarrays Problem

Given an integer array arr of size N, determine if it is possible to split the array into K consecutive non-overlapping subarrays of length M such that each su...read more

Add your answer

Q28. Equalize Water in Buckets

You are provided with an array, ARR, of positive integers. Each integer represents the number of liters of water in a bucket. The goal is to make the water volume in each bucket equal ...read more

Add your answer

Q29. Minimize Cash Flow Problem

You are provided with a list of 'transactions' involving 'n' friends who owe each other money. Each entry in the list contains information about a receiver, sender, and the transactio...read more

Add your answer

Q30. Wildcard Pattern Matching Problem Statement

Implement a wildcard pattern matching algorithm to determine if a given wildcard pattern matches a text string completely.

The wildcard pattern may include the charac...read more

Add your answer

Q31. Minimum Number of Lamps Needed

Given a string S containing dots (.) and asterisks (*), where a dot represents free spaces and an asterisk represents lamps, determine the minimum number of additional lamps neede...read more

Add your answer

Q32. Missing Numbers Problem Statement

You are provided with an array called ARR, consisting of distinct positive integers. Your task is to identify all the numbers that fall within the range of the smallest and lar...read more

Add your answer

Q33. Intersection of Two Arrays Problem Statement

Given two arrays A and B with sizes N and M respectively, both sorted in non-decreasing order, determine their intersection.

The intersection of two arrays includes ...read more

Add your answer

Q34. Next Greater Element Problem Statement

You are provided with an array or list ARR containing N positive integers. Your task is to determine the Next Greater Element (NGE) for each element in the array.

The Next...read more

Add your answer

Q35. Count Ways to Reach the N-th Stair Problem Statement

You are provided with a number of stairs, and initially, you are located at the 0th stair. You need to reach the Nth stair, and you can climb one or two step...read more

Add your answer

Q36. Linked List Merge Point Problem

You are given two singly linked lists and a third linked list, such that the two lists merge at some node of the third linked list. Determine the data value at the node where thi...read more

Add your answer

Q37. Search in a Row-wise and Column-wise Sorted Matrix Problem Statement

You are given an N * N matrix of integers where each row and each column is sorted in increasing order. Your task is to find the position of ...read more

Add your answer

Q38. Max Product Subset Problem Statement

Given an array/list arr of size n, determine the maximum product possible by taking any subset of the array/list arr. Return the result modulo 10^9+7 since the product can b...read more

Add your answer

Q39. Split Array Into Maximum Subarrays Problem Statement

You are given an integer array arr of size N. Your task is to split the array into the maximum number of subarrays such that the first and last occurrence of...read more

Add your answer

Q40. 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

Add your answer

Q41. You have a lot of small integers in an array. You have to multiply all of them. You need not worry about overflow and range, you have enough support for that. What can you do to speed up the multiplication on y...

read more
Ans.

To speed up multiplication of small integers in an array, we can use bitwise operations and parallel processing.

  • Use bitwise operations like shifting and ANDing to perform multiplication faster.

  • Divide the array into smaller chunks and perform multiplication in parallel using multi-threading or SIMD instructions.

  • Use lookup tables for frequently used values to avoid repeated calculations.

  • Use compiler optimizations like loop unrolling and vectorization.

  • Consider using specialized ...read more

Add your answer

Q42. Min Jumps Problem Statement

In Ninja town, represented as an N * M grid, people travel by jumping over buildings in the grid's cells. Santa is starting at cell (0, 0) and must deliver gifts to cell (N-1, M-1) o...read more

Add your answer

Q43. Stack using Two Queues Problem Statement

Develop a Stack Data Structure to store integer values using two Queues internally.

Your stack implementation should provide these public functions:

Explanation:

1. Cons...read more
Add your answer

Q44. Split Array Problem Statement

You are given an integer array/list arr of size N. Your task is to split the array into the maximum number of subarrays such that the first and last occurrence of every distinct el...read more

Add your answer

Q45. 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

Add your answer

Q46. Populating Next Right Pointers in Each Node

Given a complete binary tree with 'N' nodes, your task is to determine the 'next' node immediately to the right in level order for each node in the given tree.

Input:...read more

Add your answer

Q47. Good Arrays Problem Statement

You are given an array 'A' of length 'N'. You must choose an element from any index in this array and delete it. After deleting the element, you will obtain a new array of length '...read more

Add your answer

Q48. 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

Add your answer

Q49. Leaders in an Array Problem Statement

You are given a sequence of numbers. Your task is to find all leaders in this sequence. A leader is defined as an element that is strictly greater than all the elements to ...read more

Add your answer
Q50. ...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.

Add your answer

Q51. Rat In a Maze Problem Statement

Given a N * N maze with a rat placed at position MAZE[0][0], find and print all possible paths for the rat to reach its destination at MAZE[N-1][N-1]. The rat is allowed to move ...read more

Add your answer

Q52. Find K'th Character of Decrypted String

You are given an encrypted string where repeated substrings are represented by the substring followed by its count. Your task is to find the K'th character of the decrypt...read more

Add your answer

Q53. Chocolate Distribution Problem

You are given an array/list CHOCOLATES of size 'N', where each element represents the number of chocolates in a packet. Your task is to distribute these chocolates among 'M' stude...read more

Add your answer

Q54. 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
Add your answer

Q55. Cycle Detection in a Linked List

Determine if a given Singly Linked List of integers forms a cycle.

Explanation:

A cycle exists in a linked list if a node's next pointer points back to a previous node, creating...read more

Add your answer

Q56. 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

Add your answer

Q57. Ways to Reach Nth Stair

Given the number of stairs, initially at the 0th stair, you need to reach the Nth stair. Each time, you can either climb one step or two steps. Determine the number of distinct ways to c...read more

Add your answer

Q58. Top View of Binary Tree Problem Statement

Given a binary tree, your task is to print the Top View of the Binary Tree. The Top View is the set of nodes visible when the tree is viewed from the top. Please ensure...read more

Add your answer

Q59. Digit Count In Range Problem Statement

Given an integer K, and two numbers A and B, count the occurrences of the digit K in the range [A, B].

Include both the lower and upper limits in the count.

Input:

The fir...read more
Add your answer

Q60. Maximum Frequency Number Problem Statement

Given an array of integers with numbers in random order, write a program to find and return the number which appears the most frequently in the array.

If multiple elem...read more

Add your answer

Q61. Predecessor and Successor in Binary Search Tree (BST)

Given a binary search tree (BST) with 'N' nodes, find the predecessor and successor of a given 'KEY' node in the BST.

Explanation:

The predecessor of a node...read more

Add your answer

Q62. Unbounded Knapsack Problem Statement

Given ‘N’ items, each with a specific profit and weight, and a knapsack with a weight capacity ‘W’. The objective is to fill the knapsack such that the total profit is maxim...read more

Add your answer

Q63. Queue Using Stacks Problem Statement

Implement a queue data structure which adheres to the FIFO (First In First Out) principle, utilizing only stack data structures.

Explanation:

Complete predefined functions t...read more

Add your answer

Q64. Left View of a Binary Tree Problem Statement

Given a binary tree, your task is to print the left view of the tree.

Example:

Input:
The input will be in level order form, with node values separated by a space. U...read more
Add your answer

Q65. Search In Rotated Sorted Array Problem Statement

Given a rotated sorted array ARR of size 'N' and an integer 'K', determine the index at which 'K' is present in the array.

Note:
1. If 'K' is not present in ARR,...read more
Add your answer

Q66. There are N cities spread in the form of circle. There is road connectivity b/w city 1 and 2, then city 2 and 3 and so on till city n and 1. Each ith city has a petrol pump where you can pick pith petrol and di...

read more
Add your answer

Q67. Print Binary Tree Representation

Given a binary tree of integers, your task is to represent the binary tree in a 2-D array of strings with specific formatting rules.

Specifications:

  • There should be ‘H’ number ...read more
Add your answer

Q68. Zigzag Binary Tree Traversal Problem Statement

Determine the zigzag level order traversal of a given binary tree's nodes. Zigzag traversal alternates the direction at each level, starting from left to right, th...read more

Add your answer

Q69. Spiral Matrix Path Problem

You are provided with a two-dimensional array named MATRIX of size N x M, consisting of integers. Your task is to return the elements of the matrix following a spiral order.

Input:

Th...read more
Add your answer

Q70. Level Order Traversal of Binary Tree

Given a binary tree of integers, return its level order traversal.

Input:

The first line contains an integer 'T' which represents the number of test cases. For each test cas...read more
Add your answer

Q71. Binary Tree Mirror Conversion Problem

Given a binary tree, your task is to convert it into its mirror tree.

A binary tree is a data structure where each parent node has at most two children.

The mirror of a bin...read more

Add your answer

Q72. Given a program: int i; int main() { int j; int *k = (int *) malloc (sizeof(int)); … } Where are each of these variables stored?

Ans.

i is stored in global data segment, j is stored in stack, k is stored in heap.

  • i is a global variable and is stored in the global data segment

  • j is a local variable and is stored in the stack

  • k is a pointer variable and is stored in the stack, while the memory it points to is allocated on the heap using malloc()

Add your answer

Q73. Longest Common Prime Subsequence Problem Statement

Imagine Ninja is tackling a puzzle during his long summer vacation. He has two arrays of integers, each with lengths 'N' and 'M'. Ninja's task is to determine ...read more

Add your answer

Q74. Rearrange The Array Problem Statement

You are given an array/list 'NUM' of integers. Rearrange the elements of 'NUM' such that no two adjacent elements are the same in the rearranged array.

Example:

Input:
NUM[...read more
Add your answer

Q75. Tree Symmetricity Problem Statement

You are provided with a binary tree structure, where each node consists of an integer value. Your task is to determine whether this binary tree is symmetric.

A symmetric tree...read more

Add your answer

Q76. Write a client server simple code. How will you handle multiple requests? Will increasing number of threads solve the problem. What should be the optimal number of threads depending upon your computer architect...

read more
Ans.

Client-server code with optimal thread handling for multiple requests

  • Use a thread pool to handle multiple requests efficiently

  • Optimal number of threads depends on CPU cores and available memory

  • Increasing threads beyond optimal number can lead to resource contention and performance degradation

Add your answer

Q77. Suppose there is an unsorted array. What will be the maximum window size, such that when u sort that window size, the whole array becomes sorted. Eg, 1 2 6 5 4 3 7 . Ans: 4 (6 5 4 3)

Ans.

Find the maximum window size to sort an unsorted array.

  • Identify the longest decreasing subarray from the beginning and longest increasing subarray from the end

  • Find the minimum and maximum element in the identified subarrays

  • Expand the identified subarrays until all elements in the array are covered

  • The length of the expanded subarray is the maximum window size

View 1 answer

Q78. Puzzle : There is a pond in which there is x kg ice on 1st November, it becomes 2x on 2nd November then 4x,8x,16x,32x and so on.Like this whole pond is filled with ice on last day i.e. 30th November. On which d...

read more
Ans.

Puzzle: On which day in November was the pond filled with half the ice?

  • The amount of ice in the pond doubles each day in November

  • The pond is filled with ice on the last day of November

  • To find the day when the pond was half-filled, work backwards from the last day

Add your answer
Q79. What is the Diamond Problem in C++ and how can it be resolved?
Ans.

The Diamond Problem is a conflict that occurs when a class inherits from two classes that have a common base class.

  • The Diamond Problem arises in multiple inheritance.

  • It occurs when a class inherits from two classes that have a common base class.

  • This leads to ambiguity in accessing the common base class members.

  • To fix the Diamond Problem, virtual inheritance is used.

  • Virtual inheritance ensures that only one instance of the common base class is inherited.

Add your answer

Q80. 33) You are given two hour glasses(those glasses are filled with sand). One hour glass gets emptied by 4 minutes another by 7 minutes. Find how will you calculate 9 minutes. Same puzzle was asked to me in GoldM...

read more
Ans.

Using two hour glasses, one emptied in 4 minutes and another in 7 minutes, calculate 9 minutes.

  • Start both hour glasses simultaneously

  • When the 4-minute hour glass is empty, flip it again

  • When the 7-minute hour glass is empty, 4 minutes have passed

  • Flip the 7-minute hour glass again and wait for it to empty

  • When it's empty, 9 minutes have passed

Add your answer

Q81. K-Sum Path in a Binary Tree Problem Statement

You are presented with a binary tree where each node holds an integer, along with a specified number 'K'. The task is to identify and print every path that exists w...read more

Add your answer

Q82. Count Subarrays Problem

You are given an array or list consisting of 0s and 1s only. Your task is to find the sum of the number of subarrays that contain only 1s and the number of subarrays that contain only 0s...read more

Add your answer

Q83. How do you implement naming of threads from the point of view of a multi-threaded OS.Implement rand5 using rand7.Implement functions to render circles and other figures. (This was mainly about my development at...

read more
Ans.

Implementing naming of threads in a multi-threaded OS and implementing rand5 using rand7

  • Use thread ID or thread name to name threads in a multi-threaded OS

  • Implement a function that generates a random number between 1 and 7

  • Use rejection sampling to implement rand5 using rand7

  • Ensure thread names are unique to avoid confusion

  • Test the implementation thoroughly to ensure correctness

Add your answer
Q84. What are virtual destructors in C++?
Ans.

Virtual destructors in C++ are used to ensure that the correct destructor is called when deleting an object through a pointer to its base class.

  • Virtual destructors are declared in the base class and are used when deleting an object through a pointer to the base class.

  • They allow proper destruction of derived class objects.

  • Without virtual destructors, only the base class destructor would be called, leading to memory leaks and undefined behavior.

  • Virtual destructors are necessary...read more

Add your answer

Q85. Given a set of words one after another, give me a data structure so that you’ll know whether a word has appeared already or not

Ans.

Use a hash table to store the words and check for existence in constant time.

  • Create a hash table with the words as keys and a boolean value as the value.

  • For each new word, check if it exists in the hash table. If it does, it has appeared before. If not, add it to the hash table.

  • Alternatively, use a set data structure to store only the unique words and check for existence in the set.

Add your answer

Q86. 26) There are m machines. each machine generates coins of 10 g.only one machine is defective which generates coins of 9 g.how to find that defective machine in one weighing only. Now there are two defective mac...

read more
Add your answer

Q87. How much memory is made available to a user program by the kernel, is there any limit to it? What is the range of addresses a user program can have at max, what determines it?What happens if excess memory is al...

read more
Add your answer

Q88. 1>linked list node contain a string field and next.find if by concatenating all string fields the string formed is palindrome or not? 2-> merge to sorted array in which one arra is large enough to accomodate el...

read more
Ans.

The first question is about checking if a string formed by concatenating all string fields in a linked list is a palindrome or not.

  • Traverse the linked list and concatenate all string fields

  • Check if the concatenated string is a palindrome by comparing characters from both ends

  • Consider edge cases like empty linked list or single node with an empty string field

Add your answer
Q89. What are the different types of semaphores?
Ans.

Semaphores are synchronization primitives used in operating systems to control access to shared resources.

  • Binary semaphore: Can take only two values, 0 and 1. Used for mutual exclusion.

  • Counting semaphore: Can take any non-negative integer value. Used for resource allocation.

  • Mutex semaphore: A binary semaphore used for mutual exclusion.

  • Named semaphore: A semaphore that can be accessed by multiple processes.

  • Unnamed semaphore: A semaphore that can only be accessed by threads wit...read more

Add your answer

Q90. What is merge sort and Quick sort. Adv and Disadv of each and which one would u use to sort huge list and Y

Ans.

Merge sort and Quick sort are sorting algorithms used to sort arrays of data.

  • Merge sort is a divide and conquer algorithm that divides the input array into two halves, sorts each half recursively, and then merges the sorted halves.

  • Quick sort is also a divide and conquer algorithm that selects a pivot element and partitions the array around the pivot, sorting the two resulting sub-arrays recursively.

  • Merge sort has a time complexity of O(n log n) and is stable, but requires add...read more

Add your answer

Q91. There is a paragraph having million characters. You have to find out the first non –repeating character in the complete paragraph. For example:- aab cld jb then answer should be :- c

Add your answer

Q92. Puzzle: There is a grid of soldier standing. Soldier ‘A’ is chosen: The tallest men from every column and the shortest among them. Soldier ‘B’ is chosen: The shortest men from every row and the tallest among th...

read more
Ans.

Comparison of heights of two soldiers chosen based on different criteria from a grid of soldiers.

  • Soldier A is chosen based on tallest men from every column and shortest among them.

  • Soldier B is chosen based on shortest men from every row and tallest among them.

  • The height of Soldier A and Soldier B cannot be determined without additional information about the grid of soldiers.

Add your answer

Q93. Given a polygon (could be regular, irregular, convex, concave), find out whether a particular point lies inside it or outside it

Ans.

To determine if a point is inside a polygon, use the ray casting algorithm.

  • Create a line from the point to a point outside the polygon

  • Count the number of times the line intersects with the polygon edges

  • If the count is odd, the point is inside the polygon; otherwise, it is outside

Add your answer

Q94. Write a function which returns 1 when 2 is passed and return 2 when 1 is passed.1 number is missing from an array(1 to n). find thatHe just wanted sum of n terms minus sum of array solution.Now correlate the ab...

read more
Add your answer

Q95. U have n vending machine out of which 1 is defected find the defected machine in O(1) on solving this he modified it give general solution for the case in which 2 machine are defected O(1) solution were require...

read more
Ans.

To find 2 defective vending machines out of n machines in O(1) time, label each machine with a unique number and use XOR operation.

  • Label each machine with a unique number from 1 to n

  • Calculate the XOR of all the numbers from 1 to n and the XOR of all the numbers of the working machines

  • The result of XORing these two values will give the XOR of the two defective machines

  • Find the rightmost set bit in the XOR result, divide the machines into two groups based on that bit, and XOR t...read more

Add your answer

Q96. How to find a loop in a Linked List and how to remove it

Ans.

To find and remove a loop in a Linked List, we can use Floyd's Cycle Detection Algorithm.

  • Use two pointers, slow and fast, to detect if there is a loop in the Linked List

  • If the two pointers meet at some point, there is a loop

  • To remove the loop, set one of the pointers to the head of the Linked List and move both pointers one step at a time until they meet again

  • The meeting point is the start of the loop, set the next pointer of this node to NULL to remove the loop

View 1 answer

Q97. Given an expression, remove unnecessary parenthesis. For example if (((a + b)) * c) is given make it (a + b) * c, as it evaluates in the same way without those parenthesis also

Ans.

To remove unnecessary parenthesis from an expression, we need to apply a set of rules to identify and eliminate them.

  • Identify and remove parenthesis around single variables or constants

  • Identify and remove parenthesis around expressions with only one operator

  • Identify and remove parenthesis around expressions with operators of equal precedence

  • Identify and remove parenthesis around expressions with operators of different precedence

  • Apply the rules recursively until no more unnece...read more

Add your answer

Q98. Design a clock in which if you want to know about time in any region of this world, you can know .Hardware given is such that it has already built calculation device inside it. Long Discussion on various approa...

read more
Ans.

Design a clock to know time in any region of the world with built-in calculation device.

  • Create a clock with a world map and time zones marked on it.

  • Use the built-in calculation device to calculate the time difference between the user's location and the desired location.

  • Display the time in the desired location on the clock face.

  • Allow the user to input the desired location using a keypad or touchscreen.

  • Include a database of time zones and their offsets for accurate calculations...read more

Add your answer

Q99. 100 white eggs and 100 black eggs are distributed in 2 bags and now choosen a egg. The way to be distribute the eggs so that the probability of getting a black egg is maximum?

Ans.

Distribute 50 white and 100 black eggs in one bag and 50 white and 0 black eggs in the other bag.

  • Distribute the black eggs in one bag and white eggs in the other bag

  • Ensure that both bags have equal number of white eggs

  • The bag with black eggs will have a higher probability of getting a black egg

Add your answer

Q100. You are given a string in which every character is followed by space u have to return n/2 string that is each character as a separate string ..extra space were not allowed

Ans.

Given a string with characters separated by spaces, return each character as a separate string without using extra space.

  • Split the string by spaces to get an array of characters

  • Return the array of characters as individual strings

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

Interview Process at Affinity Global Advertising

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

Top Interview Questions from Similar Companies

3.9
 • 486 Interview Questions
3.4
 • 257 Interview Questions
4.2
 • 210 Interview Questions
3.9
 • 209 Interview Questions
3.2
 • 164 Interview Questions
3.4
 • 164 Interview Questions
View all
Top Adobe Interview Questions And Answers
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