Questions for Coding Assessment

1. A team of developers needs to run N APIs (i.e. Application Programming Interface) on M applications and each API can run for a certain number of minutes. All applications can be run simultaneously by developers using the APIs provided. At first, the developers used only one API per application. Once an API is started, developers can stop and restart it as many times as they want from their applications. Depending on the application, the API may be a new API or an API from another application. No time is wasted in stopping and starting API processes by an application. To optimise the process of running NAPIs on M applications, the team must find the maximum number of minutes all the applications can run simultaneously using the APIs provided.

Write an algorithm to find the maximum number of minutes all the applications can run for simultaneously using the APIs provided.

Input

The first line of input consists of an integer-api_size, representing the number of APIs (N). The next line consists of space-separated integers representing the run time for each API in minutes. The last line consists of an integer application, representing the number of applications (M).

Output

Print an integer representing the maximum number of minutes all the applications can run for simultaneously using the APIs provided.

Python
def max_simultaneous_minutes(api_size, api_runtimes, application):
    api_runtimes.sort(reverse=True)
    
    max_minutes = 0
    total_runtime = sum(api_runtimes)
    
    for _ in range(application):
        max_minutes += min(total_runtime, api_runtimes[0])
        total_runtime -= api_runtimes[0]
        api_runtimes.pop(0)
    
    return max_minutes

api_size = int(input())
api_runtimes = list(map(int, input().split()))
application = int(input())

print(max_simultaneous_minutes(api_size, api_runtimes, application))

#This code was contributed by Chayanika Arora

The first question involved optimizing the process of running N APIs on M applications to find the maximum simultaneous runtime using the provided APIs. The solution involved sorting the API runtimes, assigning the longest runtime to each application, and updating the maximum runtime. This solution had a time complexity of O(N log N) and a space complexity of O(N).

2. A chat application is building a new immersive feature for their customers to enhance their experience. To train the model for this feature, the developers have prepared a data set. In the data set, there are two columns. The first column contains a new search term

A which the user writes in the chat without spacing, and in the second column there are N unique space-separated words. The training of this new model is designed in such a way that it accepts both columns as input and returns all feasible sentences after inserting spaces in the search term A, such that each word in the sentence exists in the second column. In a sentence, a word from the first column can be used multiple times and each letter from the search term A should be used in the formation of the sentence.

In the output, the relative positions of the letters of the search term A should be the same as they are in the input.

Write an algorithm for the model to print all the feasible sentences after inserting the spaces in the search term.

Input

The first line of the input consists of a string – search term, representing the search term A without spacing. The second line of the input consists of an integer-word size, representing the total number of words in the second column. The third line of input consists of N space-separated strings – word1, word2, …, words representing the words present in the second column.

Output

Print P line separated strings, representing all the feasible sentences after inserting the spaces in the search.

Python
def generate_sentences(search_term, words):
    word_set = set(words)
    memo = {}
    
    def dp(start):
        if start in memo:
            return memo[start]
        
        result = []
        for end in range(start + 1, len(search_term) + 1):
            word = search_term[start:end]
            if word in word_set:
                if end == len(search_term):
                    result.append([word])
                else:
                    next_sentences = dp(end)
                    if next_sentences:
                        for next_sentence in next_sentences:
                            result.append([word] + next_sentence)
        
        memo[start] = result
        return result
    
    sentences = dp(0)
    result = [" ".join(sentence) for sentence in sentences]
    return result

search_term = "catsanddog"
words = ["cat", "cats", "and", "sand", "dog"]

sentences = generate_sentences(search_term, words)
for sentence in sentences:
    print(sentence)

#This code was contributed by Chayanika Arora

The second question focused on building a new feature for a chat application by training a model to generate feasible sentences from a search term and a list of unique words. The solution utilized dynamic programming with memoization to explore all possible combinations efficiently, ensuring both time and space efficiency.

Flipkart Interview Experience For SDE 1 (Off-Campus) 2024

Hi, I applied for the Software Development Engineer (SDE-1) position at Flipkart after seeing their LinkedIn post. Following the initial selection based on my resume and work experience, I received an email for an online coding assessment scheduled on April 14th, 2024. The assessment lasted for 90 minutes and comprised three coding questions with medium to high difficulty levels, conducted via SHL. It was a one-time test, and once the exam link was opened, it couldn’t be reopened or rescheduled.

Similar Reads

Questions for Coding Assessment

1. A team of developers needs to run N APIs (i.e. Application Programming Interface) on M applications and each API can run for a certain number of minutes. All applications can be run simultaneously by developers using the APIs provided. At first, the developers used only one API per application. Once an API is started, developers can stop and restart it as many times as they want from their applications. Depending on the application, the API may be a new API or an API from another application. No time is wasted in stopping and starting API processes by an application. To optimise the process of running NAPIs on M applications, the team must find the maximum number of minutes all the applications can run simultaneously using the APIs provided. Write an algorithm to find the maximum number of minutes all the applications can run for simultaneously using the APIs provided. Input The first line of input consists of an integer-api_size, representing the number of APIs (N). The next line consists of space-separated integers representing the run time for each API in minutes. The last line consists of an integer application, representing the number of applications (M). Output Print an integer representing the maximum number of minutes all the applications can run for simultaneously using the APIs provided....

Technical Interview One

After successfully passing this round, I had my first technical interview on 25th April 2024, lasting 45 minutes, with two medium to high-level coding questions. The interviewer was supportive, providing hints and discussing problem-solving approaches throughout the interview. The first question asked was based on dynamic programming where we had to use hash maps to solve the problem, I don’t exactly remember the questions. The second one was more complex, you don’t need to solve the entire problem but implement the pseudo code and explain the approaches properly to clear this round....

Other Interview Rounds

Following Technical Interview 1, I had another technical round focusing on data structures, algorithms, and problem-solving skills. Upon clearing this round, I proceeded to the HR-based interview, which included behavioural questions and discussions about my resume and motivation for joining Flipkart....

Contact Us