Bitwise Palindromic Paths
You are given a binary matrix of size N x M where each cell contains either 0 or 1. A path from the top-left cell (0,0) to the bottom-right cell (N-1,M-1) is valid if you can only move right or down at each step.
A path is called bitwise palindromic if the sequence of bits collected along the path forms a palindrome when interpreted as a string (e.g., 0110, 1, 101).
Asked in: UBER
Minimum Time to Complete Tasks with Dependencies
You are given N tasks numbered from 0 to N-1. Each task takes 1 unit of time to complete. Some tasks depend on the completion of other tasks and can only start once all their prerequisite tasks are finished. You are given a list of dependency pairs (a, b), meaning task a must be completed before task b can start.
You have unlimited resources a
Asked in: ZOMATO
Rotten Oranges
You are given an N x M grid representing a storage area for oranges. Each cell in the grid can be:
- 0: empty cell
- 1: fresh orange
- 2: rotten orange
A rotten orange at position (i, j) spreads rot to its adjacent fresh oranges (up, down, left, right) every minute. The rotting process happens simultaneously for all rotten oranges at each time step.
Your task i
Asked in: ZOMATO
Implement a prototype for a text editor application with the following functionalities:
Command
Actions:
- ["Insert", s]: Insert the string s at the current cursor position. The cursor moves right by the length of s.
- ["Left", x]: Move the cursor x positions to the left, but not past the start of the string.
- ["Right", x]: Move the cursor x positions to the right, but not past the
Asked in: MICROSOFT
Given a string, determine how many different substrings exist that have no repeating characters. Two substrings are considered different if they have different start or end indices.
Example
s = "abac"
The substrings with no repeating characters are "a", "b", "a", "c", "ab", "ba", "ac", and "bac".
Note that "aba" and "abac" do not qualify because the character 'a' is repeated in them.
Asked in: MICROSOFT
A coding competition organized to recruit software developers includes a problem involving the bitwise-OR operation. The score of a sequence is defined as the result of the bitwise-OR operation on its elements. Given an array arr of length n, identify all possible distinct scores that can be obtained by selecting any strictly increasing subsequence from the array. Return the results sorted in asce
Asked in: MICROSOFT
Java: Social Network Interaction System
Design and implement a social media platform where users can follow and unfollow each other, post content, and receive notifications about new posts from the users they follow. You should print a message when a new user is added, when a user follows or unfollows another user, and when a user posts or receives a notification.
Complete the following meth
Asked in: STRIPE
You've been asked to program a bot for a popular bank that will automate the management of incoming requests. Every request has its own timestamp in seconds, and it is guaranteed that all requests come sequentially, i.e. the timestamp is strictly increasing. There are two types of incoming requests:
. deposit <timestamp> <holder_id> <amount> - request to deposit <amount> amount of money in the
Asked in: CITYBANK
Q Trip Tag Generator Uber's platform auto-generates trip tags which are short strings summarizing key trip metadata. To validate the tagging logic, the infrastructure team is checking how many different ways a specific tag can be constructed using segments from historical tags.
You are given an array tags of length n, where each tag is a string of length m. You're also given a targetTag that ne
Asked in: UBER
Fleet Upgrades
You're building a system for Uber Fleet Management to optimize vehicle upgrades within a limited operations budget.
There are a total of n vehicles where:
- `upgradeCost[i]`: cost to upgrade the i-th vehicle
- `expectedResale[i]`: expected resale value of the i-th vehicle after one year of operation
You may choose to upgrade any vehicle once, and the total upgrade cost mu
Asked in: UBER