HP INC interview experience Real time questions & tips from candidates to crack your interview

SDE - Cloud Developer

HP INC
upvote
share-icon
3 rounds | 7 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Dynamic Programming
Tip
Tip

Tip 1 : Do lot of hard work and practice of Data Structures and Algorithms based questions.
Tip 2 : I personally recommend you Coding Ninjas and Geeks For Geeks for interview preparation.

Application process
Where: Campus
Eligibility: No criteria
Resume Tip
Resume tip

Tip 1 : Make your resume short and try to make it of one page only and do mention all your skills which you are confident of in your resume.
Tip 2 : Have some projects on resume.

Interview rounds

01
Round
Easy
Online Coding Test
Duration60 minutes
Interview date12 Apr 2022
Coding problem2

- Morning time
- Environment was good.
- No
- Interviewer was good

1. Tiling Problem

Hard
45m average time
0/120
Asked in companies
OptumOlaAdobe

You have been given a board where there are '2' rows and 'N' columns. You have an infinite supply of 2x1 tiles, and you can place a tile in the following ways:

1. Horizontally as 1x2 tile
2. Vertically as 2x1 tile

Count the number of ways to tile the given board using the available tiles.

Note :
The number of ways might be large so output your answer modulo 10^9 + 7.

Here an example of tile and board for 'N' = 4 :

Tiling Example

Problem approach

s1 - I have done this problem earlier.
s2 - so got the DP based approach during the test and this approach passed all the test cases.

Try solving now

2. Find k’th character of decrypted string

Moderate
33m average time
0/80
Asked in companies
OptumAtlassianAdobe

You have been given an Encrypted String where repetitions of substrings are represented as substring followed by the count of substrings.

Example: String "aabbbcdcdcd" will be encrypted as "a2b3cd3".

You need to find the 'K'th character of Decrypted String. Decrypted String would have 1-based indexing.

Note :

Input string will always be lowercase characters without any spaces.

If the count of a substring is 1 then also it will be followed by Integer '1'.
Example: "aabcdee" will be Encrypted as "a2bcd1e2"
This means it's guaranteed that each substring is followed by some Integer.

Also, the frequency of encrypted substring can be of more than one digit. For example, in "ab12c3", ab is repeated 12 times. No leading 0 is present in the frequency of substring.

The frequency of a repeated substring can also be in parts.
Example: "aaaabbbb" can also have "a2a2b3b1" as Encrypted String.
Problem approach

s1 - I simply decrypt the string by reading substring
s2 - their frequency and append current substring to the decrypted string and after the end of traversal of given string our answer will be kth element of the decrypted string.

Try solving now
02
Round
Medium
Face to Face
Duration30 minutes
Interview date6 Jul 2022
Coding problem2

1. Count Positive-Negative Pairs

Easy
22m average time
0/40
Asked in companies
AtlassianAmazonAmdocs

You have been given an array/list(ARR) of positive and negative integers. Print the number of pairs where:

arr[i] = -arr[j] and i != j
Note:
Given array/list can contain duplicate elements and will not contain '0'.

(arr[i],arr[j]) and (arr[j],arr[i]) are considered same.
Problem approach

s1 - I asked for some clarifications whether I should print all distinct x‘s or if I should print an x if a pair of +x and -x is encountered. The first approach I told was to use a map and I was keeping a flag for +x and -x if it’s found once.
s2 - Later he asked me to print all pairs, so I stored the frequencies of all the elements in the map and iterated through the negative elements and for each element x , I would print x min(count[-x],count[+x]) times. He said he can’t afford that much space and he wanted me to optimise space further. So I told him a 2 pointer approach where I sort the array once and then keep two pointers to the start and end. I would move the start pointer forward if the sum is less than 0 and I’ll move the end pointer backward if the sum is greater than 0. He was fine with the solution and asked me to code it in a paper. I wrote the code and walked him through it.

Try solving now

2. System Design Question

Design the logic for minimising cash flow in an app like ‘Splitwise’.

Problem approach

s1- Here the interviewer told me about an app called splitwise which i had used once. In the application each user adds the amount he spends and it’s shared equally among users of the app. The aim is to minimise the number of give and take operations. I initially thought of a very naive approach where I wanted to create classes for each person and expenditure and iterate through the expenditures of other people to find how much a person should give or take. When I took a closer look I got the idea of modelling it as a directed graph and adding directed edges for transactions. With the graph I thought of taking the difference between the pair of edges between two people to reduce a give and take operation to a single give/take operation. 
s2- There was a catch, if A has to give B Rs.10, B has to give C Rs.10, and A has to give C Rs.10, the minimum operation to do is to give Rs.20 from A to C. B is not involved here as he has to spend all he gets. So I said we could preprocess the graph with the numbers on the incoming and outgoing edges. If the total flow is 0, we could remove that node. 
s3- He seemed convinced with the approach. He gave me a graph after all the preprocessing done and finally asked me how to minimise it. So I used a greedy method. I was settling the amount of the person who has to get the largest amount by giving the amount of the people who has to give lesser amounts and he said that’ll work.

03
Round
Easy
Video Call
Duration30 minutes
Interview date16 Aug 2022
Coding problem3

- Afternoon time
- Environment was good.
- No
- Interviewer was good

1. Count Special Nodes in Generic Tree

Hard
39m average time
0/120
Asked in company
Amazon

You have been given a Generic Tree of Integers. The task is to count the number of 'Special Nodes'.

A Node is a Special Node if there is a path from the root to that Node with all distinct elements.

Problem approach

s1- I suggested to do a depth first search keeping a set which contains all elements upto a given node. Once I reach a particular node, I check if it’s already in the set. If its already in the set, I return because that element has already been visited and is not a special node.
s2- Otherwise, I increase the count of a global variable by 1 and push that element to the set. Then I go through the adjacency list of that element and call this function recursively. Once I return from the element after visiting its neighbors, I pop the element from the set. I told him the approach and he asked me to write the code for it. He was convinced with the approach and he liked the code.

Try solving now

2. Sort 0 1 2

Easy
22m average time
0/40
Asked in companies
AmazonOracleWalmart

You have been given an integer array/list(ARR) of size 'N'. It only contains 0s, 1s and 2s. Write a solution to sort this array/list.

Note :
Try to solve the problem in 'Single Scan'. ' Single Scan' refers to iterating over the array/list just once or to put it in other words, you will be visiting each element in the array/list just once.
Problem approach

s1- I solved this question using three-pointers and this problem was a variation of dutch national flag problem.
s2- The interviewer was satisfied by my approach as this was the most optimal approach.

Try solving now

3. Anagram Pairs

Moderate
30m average time
60% success
0/80
Asked in companies
NearbuyAppleAmerican Express

You are given two strings 'str1' and 'str1'.


You have to tell whether these strings form an anagram pair or not.


The strings form an anagram pair if the letters of one string can be rearranged to form another string.

Pre-requisites:

Anagrams are defined as words or names that can be formed by rearranging the letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "rasp" are anagrams. 

Other examples include:

'triangle' and 'integral'
'listen' and 'silent'
Note:
Since it is a binary problem, there is no partial marking. Marks will only be awarded if you get all the test cases correct. 
Problem approach

s1- I implemented it first by sorting two strings and comparing them. 
s2- He asked me to write a better approach. So I used a hashmap to do it.

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is recursion?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by OYO
4657 views
0 comments
0 upvotes
SDE - 1
3 rounds | 6 problems
Interviewed by HP INC
923 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 5 problems
Interviewed by Meesho
6451 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 9 problems
Interviewed by Salesforce
3452 views
0 comments
0 upvotes