Dell Technologies | SSE | Ireland (remote) | Solution added

Anonymous User
499
Aug 25, 2022
Aug 30, 2022

Had an interview with Dell for the Senior Software engineer role. The interview was an online interview over a zoom call. There were 3 in the panel, a manager, a senior principal engineer, and a senior engineer.

The interview was for 90 mins, with a managerial/behavioural round, technical Q&A, and DSA.

  • The interview started with the manager's introduction, product team etc. 10 mins gone.

  • Manager asked me about my past experiences, project and what issues I faced and how I resolved them. It was all in one go. So took a while to give the background of my work, the issues it tried to resolve. There were some follow-up questions in the middle. I wasn't comfortable with such open-ended questions because you won't know where to stop. Except for one project I didn't get a chance to discuss anything else.

  • The Senior principal engineer started grilling me on the Spring framework, and he/she kept on asking about Spring's transaction management. I tried to explain all that I can. But I couldn't answer a few questions about transaction isolations, as I had used it long back, and never had to use it extensively.

  • The accompanying engineer asked a few questions that sounded like a behavioural question. By now it was already past the first 60+ mins.

  • Now they switched to coding in the last 25 mins. there was no online platform or anything, all they gave me is a vague problem statement in chat. I asked clarifying questions for my doubts. Took me about 5 mins to clarify.

  • I could recognise it as a sliding window problem but slightly modified version. I feel likt it is on a harder side of a medium problem. All I was given was 20 mins. I could not complete it.

  • Before 10 mins left manager cut me off and told me we don't have time left and asked if I have any questions. He/She said I can complete it and send the answers later.

Since I didn't singn any NDA, i think it's okay to discuss the problem here. So here you go

In an integer array, enter  “N” times random positive numbers and display which number has the most repeating consecutive values, 
how many times does it repeat and from which integer initiates the repetition of values.

After clarification:

  • Q: Build an array with n random positive integers - A : now they gave an array {1,2,2,3,3,4,2}
  • Q: Find the most repeating, in this case, both 2 & 3 appear twice,which one to consider - A:so they said whatever comes first is fine - so print "2"  repeating 2
  • Q: From which integer initiates? what it means? - A: it means from which index the repetition starts. - so 2 starts at index 1

Don't understand what was the intent of this problem solving round. Even if it was a straight forward sliding window, i think it takes on an average of 15 mins to think through the solution and code it, unless I've seen it just few days ago :( 

Overall it was not a great experience, waiting for results.


PS: This was my solution that I sent to the manager within an hour after the interview. This is O(n2) time, is there a way to optimise this?

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toSet;

public class Demo {

    public static void main(String[] args) {

        // Number 4 repeats 12 times starting at index 11
        int[] input = {1, 2, 2, 3, 3, 4, 2,2,2,2,2, 4,4,4,4,4,4,4,4,4,4,4,2,2};

        Map<Integer, Integer> numToCount = new HashMap<>();
        Map<Integer, Integer> numToIdx = new HashMap<>();

        //First we need to identify all the numbers uniquely to iterate through it
        Set<Integer> uniqueNums = Arrays.stream(input).boxed().collect(Collectors.toSet());

        //Iterate through the unique values - find the max repeated for each with index
        for (int j : uniqueNums) {
            var pair = findLongestRepeating(input, j);
            numToCount.put(j, pair.count);
            numToIdx.put(j, pair.index);
        }
        var result = numToCount.entrySet().stream()
                .max(Map.Entry.comparingByValue())
                .orElseThrow();
        System.out.println("Highest repeating number is:" + result.getKey() + " repeating:" + result.getValue() + " times");
        System.out.println("The index at which highest repeating character starting is:" + numToIdx.get(result.getKey()));
    }

    private static Pair findLongestRepeating(int[] input, int key) {

        int count = 0;
        int left = 0;
        int index = -1;

        //Start from the left of the array
        while (left < input.length) {

            // Get a right pointer to increment in case the input[key] matches
            int right = left;
            // Check if the array element is equal to key, in our case it is the unique number we passed
            if (input[left] == key) {
                // If matches then iterate the right pointer to check;
                while (right < input.length) {
                    // if the left and right values match, then get the max count
                    if (input[right] == input[left]) {
                        count = Math.max(count, right - left + 1);
                        index = left;
                    } else {
                        break;
                    }
                    right++;
                }
            }
            // Since we have checked till the right pointer we can start again from right+1 to see if there is any repeating keys further down the array
            left = right+1;
        }

        return new Pair(count, index);
    }

    // An auxiliary structure help return both count and index. Can use apache commons but that need downloading of dependencies
    private static class Pair {
        public Integer count;
        public Integer index;

        public Pair(final int count, final int index) {
            this.count = count;
            this.index = index;
        }
    }
}
Comments (1)