Summary
This post details my approach and solution to the 'Summary Ranges' problem, which I encountered during a Yandex interview.
Full Experience
Intuition
To summarize ranges in a sorted array, we can identify segments of consecutive numbers. Whenever a gap occurs between two numbers, it marks the end of the current range
Approach
We iterate through the array while keeping track of the start of the current range using a variable s.By appending float('inf') to the list, we ensure the final range is processed without requiring additional checks after the loop
At each step, we check if nums[i] - nums[i-1] > 1, which means the consecutive sequence has ended
We then:
- Record the range from s to
nums[i-1] - Update s to start a new range
from nums[i]
If the start and end of the range are the same, we store it as a single number. Otherwise, we use the "start->end" format
Complexity
- Time complexity: $$O(n)$$ — We go through the list once
- Space complexity: $$O(n)$$ — for storing the resulting list of summary strings
Interview Questions (1)
To summarize ranges in a sorted array, we can identify segments of consecutive numbers. Whenever a gap occurs between two numbers, it marks the end of the current range. My approach involves iterating through the array while keeping track of the start of the current range using a variable s. By appending float('inf') to the list, we ensure the final range is processed without requiring additional checks after the loop. At each step, we check if nums[i] - nums[i-1] > 1, which means the consecutive sequence has ended. We then record the range from s to nums[i-1] and update s to start a new range from nums[i]. If the start and end of the range are the same, we store it as a single number. Otherwise, we use the "start->end" format.
Summary
I interviewed for a Senior+ Frontend role at Yandex with 5 years of experience. I was not hired primarily due to a lack of knowledge in CI/CD, deployment processes, and backend concepts, despite performing well on various technical and algorithmic challenges.
Full Experience
Platform, Algorightms:
- Implement Array.groupby
- Given 2 arrays of intervals find their intersections
- Implement Promise.all, Promise.any
- Implement lodash.debounce (something similar)
- Implement lodash.get
- Does string
sexist in subsequence ofk - Simple hashmap. Messages apear in non consecutive order (let's assume via websockets). We need to log them consecutevly when they appear. Eg messages appear like so
1,3,2,4. First we log1. Then remember3. Then log2and3when we get2. Then log4.
Finals:
- Why we use SSR?
- CI\CD. Have you ever worked with?
- Testing. Why we use it? What types of testing did you use?
- Cases with optimizing your codebase?
- Hardest project\task you ever worked with. How did you deal with that?
Vertict: No hire.
Reason: Don't know CI\CD, Deploy, and backend
Interview Questions (12)
Implement the Array.groupby method.
Given 2 arrays of intervals, find their intersections.
Implement JavaScript's Promise.all and Promise.any methods.
Implement a debounce function similar to lodash.debounce.
Implement a function similar to lodash.get for safely accessing nested object properties.
Given two strings, s and k, determine if s exists as a subsequence of k.
Implement a system to log messages consecutively, even if they appear in a non-consecutive order (e.g., via websockets). For example, if messages appear as 1,3,2,4: First, log 1. Then, remember 3. When 2 arrives, log 2 and then 3. Finally, log 4.
Explain the reasons and benefits of using Server-Side Rendering (SSR).
Discuss your experience with Continuous Integration and Continuous Deployment (CI/CD).
Explain why testing is important and describe the types of testing you have experience with.
Describe scenarios where you optimized a codebase and the approaches you took.
Describe the hardest project or task you've worked on and how you approached and resolved it.