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

Software Engineer

HeyCoach
upvote
share-icon
1 rounds | 3 Coding problems

Interview preparation journey

expand-icon
Journey
I maintained a consistent daily routine by solving at least one DSA problem using different approaches, revising JavaScript concepts, practicing aptitude problems, and learning from others through YouTube podcasts. This helped me strengthen problem-solving skills, deepen understanding of core concepts, and stay updated with industry practices.
Preparation
Topics: DSA, Javascript
Application process
Where: Coding Ninjas Placement Cell
Eligibility: B.E./B.Tech/M.E./M.Tech./BCA/MCA

Interview rounds

01
Round
Medium
Online Coding Interview
Duration
Interview date6 Mar 2025
Coding problem3

1. Find longest subarray of sum zero

Given an integer array, find the length of the longest contiguous subarray whose sum of elements is zero.

Input: An array of integers, e.g., [1, 2, -3, 3, -1, -2]
Output: An integer representing the length of the longest subarray with sum zero.

 

Constraints:

  • The array can contain positive, negative, and zero values.
  • The array length can be up to 10^5 elements.
Problem approach

First, let us initialize a variable say sum = 0 which stores the sum of elements traversed so far and another variable says max = 0 which stores the length of the longest subarray with sum zero. Declare a HashMap which stores the prefix sum of every element as a key and its index as a value. Now traverse the array, and add the array element to our sum.

2. Top view of a Binary Tree

Given a binary tree, return the values of the nodes that are visible when the tree is viewed from the top. The top view includes only the nodes that are the first encountered at each horizontal distance from the root when viewed from above.

Problem approach
  • Map: Stores the first node at each vertical index (key = vertical, value = node).
  • Queue: Perform BFS, storing nodes with their vertical indices.
  • BFS Steps:
    • Dequeue node; if vertical not in map, add it.
    • Enqueue left child with vertical-1, right child with vertical+1.
  • Result: Sort map by vertical index to get the top view.

3. Maximum Subarray

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

 

Problem approach

Kadane’s Algorithm Approach:
We iterate through the given array using a single loop and maintain a variable sum to store the sum of the current subarray. At each step, we add the current element to sum. If sum becomes negative at any point, we reset it to 0, since a negative sum would decrease the sum of any subsequent subarray. During the iteration, we keep track of the maximum sum encountered so far and return it as the result.

Note: If the array contains all negative numbers, initialize maxSum with the first element to ensure correctness.

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
4 rounds | 8 problems
Interviewed by Amazon
8518 views
0 comments
0 upvotes
Analytics Consultant
3 rounds | 10 problems
Interviewed by ZS
907 views
0 comments
0 upvotes
company logo
SDE - Intern
1 rounds | 3 problems
Interviewed by Amazon
3320 views
0 comments
0 upvotes
company logo
SDE - 2
4 rounds | 6 problems
Interviewed by Expedia Group
2580 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Software Engineer
3 rounds | 7 problems
Interviewed by Optum
7874 views
1 comments
0 upvotes
company logo
Software Engineer
5 rounds | 5 problems
Interviewed by Microsoft
9973 views
1 comments
0 upvotes
company logo
Software Engineer
2 rounds | 4 problems
Interviewed by Amazon
4310 views
1 comments
0 upvotes