Code-pen based coding problem. 2 problems. Moderate to high difficulty level. Dynamic programming and sliding window-based problems.
A. Coding round (dynamic programming and sorting based).
B. System design: How would you store files in a system where millions of photos are uploading? Basically, design a high-performance file storage system.
Given a list of houses, each painted with one of three colors, you want to minimize the cost of painting all the houses such that no two adjacent houses have the same color. You are provided with a 2D array where each element represents the cost of painting a house with a specific color. How can you implement a Java program to calculate the minimum cost to paint all houses while adhering to the color restriction?
You are given an array of words (strings) and an integer k. Your task is to write a function that returns the k longest words from the array. If there are fewer than k words in the array, return all the words sorted by length in descending order. If there are ties in length, return the words in alphabetical order.
Input:
words where each string consists of lowercase and uppercase letters only.k (1 ≤ k ≤ 100).Output:
An array of the k longest words, sorted by length (and alphabetically if lengths are equal).
Example:
Input: words = ["apple", "banana", "kiwi", "grape", "watermelon"], k = 3 Output: ["watermelon", "banana", "apple"]
Input: words = ["cat", "bat", "rat"], k = 5 Output: ["bat", "cat", "rat"]
Constraints:
The following metrics were computed from 1 interview experience for the Apple Senior Java Developer role in Gurgaon, Haryana.
Apple's interview process for their Senior Java Developer roles in Gurgaon, Haryana is extremely selective, failing the vast majority of engineers.
Candidates reported having very negative feelings for Apple's Senior Java Developer interview process in Gurgaon, Haryana.