Open In App

MountBlue Interview experience For SDE-1 (2023)

Last Updated : 07 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Round 1:

MountBlue Technologies uses the hacker rank platform for their hiring process to solve 122 coding problems

Within 4 weeks but there is no time limit. I solved all the questions in 3 weeks.

After submitting the within 10 days, I got the interview schedule mail.

I booked my slot on Dec 2 at 10 AM 2023.

Round 2: (Live Coding)

Question 1 on String:

A function that takes a string text and expands it as per the following rules

INPUT→OUTPUT

“3M2u5b2a1s1h2i1r”→ “MMNuubbbbbaashiir”

“3M123u42b12a”→ “MMMuuubbaa”

“airforce”→ “airforce”

Java




/*package whatever //do not write package name here */
 
import java.io.*;
 
public class StringExpansion {
 
    public static String stringExpansion(String txt) {
        StringBuilder result = new StringBuilder();
        int count = 0;
 
        for (char c : txt.toCharArray()) {
            if (Character.isDigit(c)) {
                count = Character.getNumericValue(c);
            } else {
                result.append(String.valueOf(c).repeat(Math.max(0, count)));
            }
        }
 
        return result.toString();
    }
 
    public static void main(String[] args) {
        System.out.println(stringExpansion("3M2u5b2a1s1h2i1r"));  // Output: "MMNuubbbbbaashiir"
        System.out.println(stringExpansion("3Hat"));               // Output: "HHHaaattt"
        System.out.println(stringExpansion("3M123u42b12a"));      // Output: "MMMuuubbaa"
    }
}


Python




def stringExpansion(txt):
    res=""
    cnt=0
 
    for char in txt:
        if char.isdigit():
            cnt=int(char)
        else:
            res+= char * cnt if cnt > 0 else char
 
    return res
print(stringExpansion("3M2u5b2a1s1h2i1r"))  # Output: "MMNuubbbbbaashiir"
print(stringExpansion("3Hat"))  # Output: "HHHaaattt"
print(stringExpansion("3M123u42b12a"))  # Output: "MMMuuubbaa"


Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].

Example 1:

Input: nums = [1,2,3,4]

Output: [24,12,8,6]

Example 2:

Input: nums = [-1,1,0,-3,3]

Output: [0,0,9,0,0]

Python




def product_except_self(nums):
    n = len(nums)
    left_products = [1] * n
    right_products = [1] * n
    left_product = 1
    for i in range(1, n):
        left_product *= nums[i - 1]
        left_products[i] = left_product
    right_product = 1
    for i in range(n - 2, -1, -1):
        right_product *= nums[i + 1]
        right_products[i] = right_product
    result = [left_products[i] * right_products[i] for i in range(n)]
    return result
 
nums_input = [1,2,3,4]
nums_input2 = [-1,1,0,-3,3]
result_arr = product_except_self(nums_input)
result_arr2 = product_except_self(nums_input2)
print(result_arr)
print(result_arr2)


Along with

  • mutable and immutable
  • what are the solid principles


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads