You are on page 1of 11

CODING ROUND:

1. Maximum Score: An interviewer at HackerRank recently came up with an interesting


problem for the candidates.
● Given an array arr of n integers, start with a score of 0. In one operation, one
element of the array is chosen, and its value is added to the score. The element is
replaced by the integer ceiling of one-third of its value. For example, if the
element is 10, then 10 is added to the score and the element is replaced by
ceil(10/3)=4.
● The task is to find the maximum possible score after koperations.

2. Purchase optimization: (Time limit: 60 mins) Alex is shopping at Ozone Galleria Mall.
There is a dedicated cubicle for a type of product at the shopping center. All the
products sold at the ith cubicle are priced the same, denoted by prices[i]. The cubicles
are arranged such that the price of the products soldat each cubicle are in
non-decreasing order.
● Several queries would be asked about the problem. In each query, the cubicle
number Alex is initially standing at, and the amount of money Alex has is given,
and Alex can travel in the right direction visiting from the current cubicle to the
last cubicle. Alex may buy at most one item from any cubicle visited, but the total
cost of the purchase must not exceed the amount Alex has. Report the maximum
number of products that can be purchased for each query.
● More formally, given an array of n integers, prices, where prices[i] denotes the
price of the product sold in the ith cubicle. The array prices are in non-decreasing
order (i.e., the price[i]≤ price[i+1]), and q queries need to be processed. For each
query, two integers are given:
pos: Alex’s initial position amount: the amount of money Alex has
● Alex needs to visit each cubicle from number pos to n, purchasing at most one
product from each cubicle. For each query, the goal is to find the maximum
number of products that Alex can buy.

3. The first question was an application of two pointer approach and sorting,
4. The second question was a slight modification of reverse-Pair, the modification was that
we need to find the maximum no. of inversions among all numbers(numbers were
unique).
5. https://leetcode.com/problems/longest-increasing-subsequence/
6. https://leetcode.com/problems/sell-diminishing-valued-colored-balls/
7. https://www.geeksforgeeks.org/compute-before-matrix/
8. https://leetcode.com/problems/minimum-falling-path-sum/
9. https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/
10. https://www.geeksforgeeks.org/count-triplets-with-sum-smaller-that-a-given-value/
11. Given a string consisting of letters that indicate directions i.e. ‘L’ for left, ‘R’ for right, ‘U’
for, up and ‘D’ for down, find the minimum length of string that can be obtained after
deleting some characters of the string so that we reach the same destination as the
original string.
12. Given ‘n’ Jars filled with ‘m’ number of Jellybeans. ‘T’ represents the number of
operations performed on these jars. Given a range [a-b] and number of jelly beans to be
filled in the jars lying in the range [a-b], find the number of jelly beans in each jar after
these ‘T’ operations.
13. Question 2: Given a number ‘N’ and an array a[ ], find the number of possibilities of
a[i]-a[j]=N such that i>j. (Could be solved in O( n ) using a HashMap).
14. Question 3: Given the number of nodes and the number of edges connecting these
nodes, arrange these edges such that maximum number of nodes are strongly
connected. Return the number of nodes that could be strongly connected. A node is said
to be strongly connected if that node is connected to every other node in the graph
(Derived a formula for it and solved in O(1) –worked for 10/14 testcases).
Formula: (No:Of Edges*2)=(x^2-x) where x represents the number of strongly connected
nodes. Solve the equation for x. Could be reduced as (1+Math.sqrt(1+(8*edges)))/2. The
approximation produced an error of +(-) 1.
15. Question 4: https://www.hackerrank.com/contests/w1/challenges/volleyball-match
(Solved this using Combinatorics in O(1)).
16. Find the number of islands
17. https://www.geeksforgeeks.org/maximum-profit-by-buying-and-selling-a-share-at-most-
twice/
18. Merging two arrays, largest sum contiguous array, sql query to find nth maximum tuple,
polymorphism, lru cache, routing and finding whether the given two linked list intersect.
19. One ques is from DP(easy one like 0-1 knapsack) and other is Activity Selection
Problem).
20. https://algodaily.com/companies/visa
21. https://workat.tech/company/visa/interview-questions/problem-solving?status=all
22. https://www.codingninjas.com/codestudio/interview-bundle/visa
23. Ninja has been asked to organize a dance competition. Ninja decided that he will take
individual entries and then will divide them into pairs. As part of the entry, he asked the
participants to choose any number. Ninja then thought of a creative method to divide
them into pairs. He decided that he would select a number ‘K’, and then select numbers
from the list that have a difference equal to ‘K’. You need to help Ninja in finding the
number of distinct pairs from the numbers with differences equal to ‘K’.

Example: Let us suppose the numbers are chosen by participants: [2, 6, 5, 2, 3] and K =
3, then the distinct pairs having differences equal to K are: [2, 5] and [3, 6] so print 2.

Note: The list of numbers can contain duplicate numbers, you need to print only the
distinct pairs. For example [2, 2, 3, 4] and K = 1, so you need to print 2 as the two distinct
pairs are: (2, 3) and (3, 4).

Input Format: The first line contains a single integer ‘T’ representing the number of test
cases. The first line of each test case will contain two space-separated integers ‘N’ and
‘K’, where ‘N’ denotes the number of elements of the array that contains the chosen
numbers, and ‘K’ denotes the difference required between the pair elements. The
second line of each test case will contain ‘N’ space-separated integers denoting the
chosen numbers by the participants.

Output Format: For each test case, print a single integer that denotes the distinct pairs
having differences equal to K. Output for every test case will be printed in a separate
line.

Constraints: 1 <= T <= 10^2 0 <= N <= 10^4 0 <= K <= 10^4 0 <= ARR[i] <= 10^9 Where
‘ARR[i]’ is the value of elements of the array. Time Limit: 1 sec

24. Maximum length sub-array having absolute difference of adjacent elements either 0 or
1. Given an array ‘A’ of ‘N’ integers, you need to find the maximum length of the
sub-array such that the absolute difference between the adjacent elements of the
sub-array should be either 0 or 1. A sub-array is a contiguous section of original
elements of the array.
For Example: Let us say A = [2,4,6,7,6,9], then adjacent elements of sub array [6,7,6]
have absolute difference of either 0 or 1 and this is the maximum length sub-array. So
the required answer will be 3.

Input Format: The first line contains a single integer ‘T’ denoting the number of test
cases. The first line of each test contains an integer ‘N’ - number of elements in the
array. The second line of each test case contains ‘N’ space-separated integers that make
up ‘A’.

Output Format: For each test case, print a single line containing a single integer
denoting the maximum length of sub-array having an absolute difference of adjacent
elements either 0 or 1. The output of each test case will be printed in a separate line.

Note: You do not need to print anything, it has already been taken care of. Just
implement the given function.

Constraints: 1 <= T <= 50 1 <=N <= 10 ^ 4 -10 ^ 8 <= A[ i ] <=10 ^ 8 Where ‘T’ is the
number of test cases, ‘N’ is the number of elements in the array, A[i] is an array element
at index ‘i’. Time limit: 1 sec.
27. https://leetcode.com/discuss/interview-question/862371/visa-online-assessment

TECHNICAL ROUND QUESTIONS


1. LC easy and medium questions
2. Dependency Injection
3. Basics OOPS questions
4. Stack questions and some other leetcode questions
5. I was asked LC medium Questions which was mainly on arrays, Stacks and LinkedLists
6. [ Generate parenthesis for number n: example: n=2 => ()(), (())
7. https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/
8. Java basics
9. LRU cache
10. In-depth concepts of Microservices and deployments
11. Java ,Multithreading,RDBMS,
12. Design and finally a Hackerrank round
13. Diagonal Sum of BT
14. Count subarrays with sum k
15. Check duplicates in arrays
16. Project related questions
17. deletion in singly link list and sorting a singly linklist
18. What's the difference between final, finally & finalize keyword
19. why we use Wrapper class in Java
20. finding a all duplicate files in the file system
21. finding duplicate element in an array of integers
22. string manipulation question
23. different valid sudoku's for a given nxn matrix
24. Given the info that a moon becomes full moon on 1st day of month and goes to no
moon on 15th day of month and back to full moon on last day of month. what is the
percentage of moon visible?
25. Write code to find whether a string is palindrome ignoring the case (upper/lower) and
ignoring special characters and the algorithm should be inplace.
26. Non overlapping intervals from leetcode
27. How to find the shortest distance between two strings in an array of string?
28. How two combine two list without creating another list.
29. Island problem
30. find max in an array of fixed window
31. Multi-Threading in java
32. Puzzle
33. Given an Input determine if its greater than a given Limit, the Limit can be invalid if it is
less than zero or greater than MAXIMUM. If Limit is invalid compare it with Default
value.
34. Maximum subarray problem
35. How to find the loop in a linked list?
36. if a string 2 strings are anagrams or not
37. Find Common Ancestor of two nodes of an N-Ary Tree.
38. Check if a loop exists in a linked list if so find the loop starting point and remove the loop
39. String anagram
40. Check if a tree is a BST
41. Given the middle of a Linked List only, remove that middle node and return the new
middle node
42. OOPS
43. Final keyword
44. equals and hashcode
45. design a multi threading solution for n process with m processor with process
dependency among each other ?
46. DAG traversal.
47. Remove a node from BST.
48. Sort a stack recursion.
49. Dp problems related to fibonacci
50. Prime numbers
51. Floyd Warshall
52. implement a hash map, inheritance, collections, custom array list, etc
53. -find n-th highest number from given array (which can may hold duplicate values ,
unsorted ) etc.
54. implement DLL using stacks.
55. Difference between XML and JSON
56. Determine if the given Queue is a circular queue.
57. Zig-zag traversal of binary tree
58. Check for balanced parentheses in an expression
59. Missing number in an array consisting of numbers 1 to N
60. Write an SQL query demonstrating self-referential join
61. With Clause in PL/SQL
62. Coding exercise to find the depth of the ancestors in a tree.
63. Visit all the nodes of a binary search tree level by level.
64. write a method to reverse all letters in a string, then support how efficient it is or could
you do better. Hint remember big-o algorithm complexity
65. First Non Repeated Character in a string
66. Recursion in java
67. Diff between SOAP and REST
68. Method over ridding and different between start and run method in Thread
69. Given an array of integers, return an array where each respective location contains the
product of the numbers except the one that occupied this same location in the input
array. Thus, given in={1,2,3}, out={6,3,2}.
70. Describe how OAuth works.
71. Given a grid containing 0s and 1s and source row and column, in how many ways, could
we reach form source to target. ( 1's represents a blockade and 0's represent accessable
points)
72. High Level System Design -> Design Uber like Service. Follow up -> What would be your
tech stack for designing such a service to make sure it could scale when needed.
73. (HLD) -> Design a service which combines multiple sources of data/documentation and
aggregates it such that all info is available centrally.
74. Spring boot API endpoint description
75. CI CD pipeline, Docker Kubernetes
76. Create an individual thread for each integer in the array and sleep the thread for integer
value of the array element.
77. After the thread sleep time is completed, add it to the output
78. Problem to accommodate N people in M rooms with k constraints such that two people
can’t be in the same room.
Return true if can be accomodated in M rooms given the constraints.
N=3
M=2
k={1,2},{3,2} 1 & 2 cannot be in same room , 3 & 2 cannot be in same room
Ans : true (only 2 rooms are required) = In one room person 1 and 2 can be
accomodated and in another person 3
79. A video game developer is developing a game in which the character makes their way
through several segments of a level. In each segment, if the character collects a coin the
player scores 1 point. However, if the segment does not have a coin 1 point is deducted
from the total score.Player 1 always begins the level and, at some point, the game play is
turned over to Player 2 to complete the level. Player1's goal is to achieve heigher score
than Player 2 once the level is completed. Given the segment status(whether they
contain the coin or not), find the minimum number of segments Player1 should play so
that, in the end Player1's score is greater than Player2.

Example: [1,1,0,1]
Player 1 has the follwoing option:

● Play 0 segment- Player1's score 0 and Player2's score ->3-1=2(3 points for segments with
coin and -1 for no coin segment)
● Play 1 segment- Player1's score 1 and Player2's score -> 2-1=1
● Play 2 segment- Player1's score 2 and Player2's score -> 1-1=0

So the answer is 2.

What can be optimized solution


80. Find the minimum number of operations required to make a string "similar".
A String is similar if the number of vowels equals the number of consonants.

A character can be increased or decreased only once at a time.


'a' cannot be decremented and 'z' cannot be incremented further.

eg: abcd
operation: 1
b->a and hence aacd
eg: bigbangt
operations: 2
first change one 'b' and the next interation change next 'b'
81. There is an array of length n you have to apply minimum number of operations on the
array elements such that for any pair of adjacent elements (arr[i]%2!=arr[j]%2)(more
formally two even number or two odd numbers should not be adjacent to each other)
you can divide an array element by 2 possibly zero or any number of times dividing an
array elemnt by 2 will be counted as 1 operation.

Constraint:(n<=10^5)

82. Given a root directory, traverse the directory through its sub directories, to each of the
files. Output the list of sets of files having the same content.
Input: '/home'
Output:'/home/users/abc.txt' '/home/test/ijk.csv'
'/home/node/app.js' '/home/node/project1/index.js'
'/home/java/main.java' '/home/java/project2/main.java'
83. Senior Engineer, Coding
Given a Huge dictionary of words, and an input stream, return a set of words, which
exist in the input stream. Input stream: "skfjhhelloasjfh sadiokdjnfn..........."
(Input Stream could be random with or without spaces)
Dictionary: foo
smile
sad
bad
hello .... and so on
Output: hello, sad
84. O(n2) was acceptable, but was asked to give a verbal solution of O(n) (KMP or Z
algorithm).
85. https://leetcode.com/problems/valid-parentheses/
86. https://algodaily.com/companies/visa
87. https://www.codingninjas.com/codestudio/interview-experiences/visa/visa-interview-ex
perience-by-on-campus-nov-2020-505?page_type=v2
88. https://www.codingninjas.com/codestudio/interview-experiences/visa/visa-interview-ex
perience-by-on-campus-aug-2021-1131?page_type=v2
89. https://www.codingninjas.com/codestudio/interview-experiences/visa/visa-interview-ex
perience-by-mudit-garg-off-campus-jul-2021?page_type=v2
90. https://www.codingninjas.com/codestudio/interview-experiences/visa/visa-interview-ex
perience-on-campus-dec-2016-1641?page_type=v2
91. https://www.codingninjas.com/codestudio/interview-experiences/visa/visa-interview-ex
perience-by-426-aman-gupta-t15-on-campus-sep-2022?page_type=v2
92. https://www.softwaretestingo.com/visa-interview-questions/
93. Find 'k' largest element in stream of integers.
Constraints -
1) k can vary for every query
2) Stream can not be stored
94. https://www.hackerrank.com/challenges/array-and-simple-queries

Given two numbers N and M. N indicates the number of elements in the array A[](1- indexed)
and M indicates number of queries. You need to perform two types of queries on the array
A[] .
You are given M queries. Queries can be of two types, type 1 and type 2.

Type 1 queries are represented as 1 i j : Modify the given array by removing elements from
to and adding them to the front.

Type 2 queries are represented as 2 i j : Modify the given array by removing elements from
to and adding them to the back.

Your task is to simply print | A[1] - A[N] | of the resulting array after the execution of M
queries followed by the resulting array.
Note While adding at back or front the order of elements is preserved.
95. https://prepfully.com/interview-questions/visa

LEETCODE QUESTIONS:
1. Find kth largest element in a BST
https://leetcode.com/problems/kth-smallest-element-in-a-bst
2. Explain merge sort.
3. https://leetcode.com/problems/partition-equal-subset-sum
4. Given 2 strings find minimum characters need to be removed to make them anagrams of
each other
https://www.geeksforgeeks.org/remove-minimum-number-characters-two-strings-beco
me-anagram
5. DP question similar to https://leetcode.com/problems/unique-paths-ii/
6. DP question : https://leetcode.com/problems/get-the-maximum-score/
7. Binary Tree Maximum Path Sum :
https://leetcode.com/problems/binary-tree-maximum-path-sum/
8. How Static methods and instance methods take part in multi-threaded application.
9. HashMap internal implementation, changes in java 1.8 onwards.
10. When to override equals and hashcode method.
11. https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-
color/
12. https://leetcode.com/problems/search-in-rotated-sorted-array/
13. https://leetcode.com/problems/3sum/
14. https://leetcode.com/problems/group-anagrams/
15. https://leetcode.com/problems/merge-intervals/
16. https://leetcode.com/problems/strange-printer/
17. https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
18. https://leetcode.com/problems/lru-cache/
19. https://leetcode.com/problems/two-sum/
20. https://leetcode.com/problems/longest-substring-without-repeating-characters/
21. https://leetcode.com/problems/remove-nth-node-from-end-of-list/
22. https://leetcode.com/problems/generate-parentheses/
23. https://leetcode.com/problems/gas-station/
24. https://leetcode.com/problems/design-hashmap/
25. https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
26. https://leetcode.com/problems/degree-of-an-array/
27. https://leetcode.com/problems/maximum-subarray/
28. https://leetcode.com/problems/median-of-two-sorted-arrays/
29. https://leetcode.com/problems/reformat-date/
30. https://leetcode.com/problems/merge-k-sorted-lists/

REDDIT:

1. Merge Sorted Array (3 times): https://leetcode.com/problems/merge-sorted-array/


2. Search in Rotated Sorted Array (3 times):
https://leetcode.com/problems/search-in-rotated-sorted-array/
3. Break a Palindrome (2 times): https://leetcode.com/problems/break-a-palindrome/
4. Greatest Common Divisor of Strings (2 times):
https://leetcode.com/problems/greatest-common-divisor-of-strings/
5. Consecutive Numbers Sum (2 times):
https://leetcode.com/problems/consecutive-numbers-sum/
6. Top K Frequent Words (2 times): https://leetcode.com/problems/top-k-frequent-words/
7. First Unique Character in a String (2 times):
https://leetcode.com/problems/first-unique-character-in-a-string/
8. Meeting Rooms II (2 times): https://leetcode.com/problems/meeting-rooms-ii/

GEEKS FOR GEEKS

1. Maximum Length Palindrome


2. Find the point where maximum intervals overlap
3. Given a function and some text cases i needed to design an algorithm to determine how
many lines of code were executing for each testcase.
4. Merging two arrays,
5. largest sum contiguous array,
6. sql query to find nth maximum tuple,
7. polymorphism,
8. lru cache,
9. routing and
10. finding whether the given two linked list intersect.
11. Given a txt file containing strings write a program to copy the strings with more than 2
vowels to another file.

You might also like