GeeksforGeeks App
Open App
Browser
Continue

# Salesforce Internship Interview Experience | On Campus 2021

Salesforce came to our campus to hire interns. The questions asked in each round were as follows.

Coding Round – This round had 3 questions to be done in 90 minutes.

1. An n*m grid of bulbs was given. Some were on (denoted by ‘O’) and some were off (denoted by ‘X’). When you toggle the state of a bulb, the state of the bulbs adjacent to it gets toggled too. Return the minimum number of toggles needed to switch all the bulbs off or -1 if it is not possible. Constraints on n, m were 18. I did the problem using BFS, where two states were connected if they were one toggle away. This passed 5 out of 6 test cases and gave one TLE.
2. An array color[] was given where color[i] represented the color with which a pencil had to be colored. There was one paintbrush corresponding to every color and we had to wait b seconds before using the same brush again. Forgiven b and color[] find the minimum time it takes to color all the pencils. A basic greedy solution based on counting the times each color is required was enough to pass all the test cases. A number of pencils, number of distinct colors, and all were given to be less than 100.
3. A target price was given. Two arrays having crust prices and toppings prices were given. The same topping could be used at most thrice. We had to create a pizza with the closest price to the target price possible. The price could be more than the target price as well. But if there is a draw we had to return the lower price. I iterated on the crust prices and found the closest value to the remaining amount via backtracking. This was enough to pass all the test cases. The number of crusts was less than 10 and the number of toppings was less than 18.

Students who were able to solve 2 problems were called up for interviews. 20 students were called for the interview.

First Interview: The interviewer first introduced himself and then asked me to introduce myself. This part was over within 5 minutes. Then he gave me the question. Before giving me the question, he told me that it is the approach that matters, we will discuss different approaches and compare them. The question was to generate all permutations of a given string that had no repeating characters. I immediately gave him an approach and wrote some pseudo-code. He then asked me to dry run on a small example which I did. He then presented an alternate approach, which we discussed upon. Then I told him why his approach was slightly better than my first approach and he was impressed. Then he asked me to implement his approach which I did. He ran the code and it worked first try.

He then proceeded on to ask some other questions. He asked me when would you use an abstract class and when would you use an interface. I gave him some generic differentiating points and he was satisfied. He then asked me whether I know about design patterns. I said I have worked with spring so I have heard about dependency injection but I am not an expert. The next question was about database indexes and I told him we haven’t covered the topic in college. He smiled and ended the interview.

In 20 minutes I was called for the next interview. 17 students were called for the second interview.

Second Interview: Similar intro stuff. This was solely a coding interview. He gave me two questions. The first one was given an array of sides, construct a triangle with the largest perimeter. This was pretty easy. I told him I would sort the array and start checking in groups of three from the last element. I told him we only need to check three consecutive elements. Since, A[i] <= A[i+1] <= A[i+2], the only inequality we need to satisfy is A[i]+A[i+1] > A[i+2], if this condition is satisfied, we should return immediately, if not there is no point of keeping A[i+2] as any element before A[i] will not help us getting a bigger sum. He was okay with this answer but asked me if I could do it in O(n). I couldn’t at first, but then he gave me a hint of using priority_queue. I couldn’t get the hint immediately but ended up getting what he wanted me to do. I said we could heapify the array in O(n) and then do the same thing with the top 3 elements. Practice problem link, Article link

Then we moved on to the next question. An array of characters is given which has to be considered as the natural ordering of the alphabets. After this return whether a given list of words is sorted or not. I said I would create an alternate list where the first character will be replaced with ‘a’, second with ‘b’ and so on. He acknowledged that I was on the right track but asked me to better my approach memory-wise. I took a minor hint and then overloaded the <= operator to compare strings on the basis of the given ordering. He was satisfied and the interview was over. Link to article

In an hour I was called for the HR round. 12 students were called for the HR interview.