The longest diagonals of a square matrix are defined as follows:
- The first longest diagonal goes from the top-left corner to the bottom-right corner.
- The second longest diagonal goes from the top-right corner to the bottom-left corner.
Given a square matrix, your task is to swap its longest diagonals by exchanging their elements at the corresponding positions.
Example:
matrix = [[1,
Asked in: INFOTECH
3. Cluster Queries
In a Salesforce global infrastructure, there are customer support clusters numbered from 1 to clusters, distributed across multiple regions. These clusters are interconnected by n communication links, represented by the array connections, such that if two clusters are connected directly or indirectly, they belong to the same support network.
Each cluster has a case resolut
Asked in: SALESFORCE
2. Salesforce Latency Optimization
Given a Salesforce infrastructure with API nodes, cloud regions, and API edges (bidirectional API connections between them), the i-th connection links regions api_from[i] and api_to[i] with a latency of api_weight[i]. The max-latency of a region is the maximum latency of any API within that region.
Split this infrastructure into at most k independent region
Asked in: SALESFORCE
1. Salesforce Cloud server requests
In a Salesforce multi-cloud architecture, there is a circular network of m cloud servers, numbered from 1 to m, where servers 1 and m are adjacent. These servers handle various customer requests, and the latency between switching from one server to the next or the previous is given by an array, transitionTime[i], representing the time required to transition f
Asked in: SALESFORCE
Directory Structure (SDE Question) - Part A
You are given a directory structure represented as a tree, where each node represents a directory that can have any number of child directories.
- Each child directory will have a unique name.
- The second line of the input will contain the root name and its child directories.
Based on the given input, you have to construct the directory struct
Asked in: NAMMA_YATRI
Problem Statement
You are given an array arr of positive integers of size n. Each value in the array represents the number of toffees in a packet. Each packet can have any number of toffees. For example, if arr = [2, 3], this means that the first packet has 2 toffees and the second has 3 toffees. There are x students. The task is to distribute toffee packets among x students such that:
- Eac
Asked in: DataTroops
There are N trolleys used to transport products and each trolley is given a unique ID from 0 to N-1. A trolley operates for a certain time period and is able to carry products. For each trolley, the automated system stores three parameters i.e., the start and end time of operation (both inclusive) and units of products carried. A trolley can be operated within a specified period. No two trolleys c
Asked in: FLIPKART
Given three points a(x1, y1), b(x2, y2), and c(x3, y3), determine if they form a non-degenerate triangle. Then, check if two points, p(xp, yp) and q(xq, yq), are inside or on the triangle.
Return the corresponding scenario number:
0. The lines do not form a valid non-degenerate triangle.
1. Point p is inside the triangle, but point q is not.
2. Point q is inside the triangle, but point
Asked in: MEESHO
Vowel SubString
Given a string composed of lowercase letters within the ASCII range 'a'-'z', determine the number of substrings that consist solely of vowels, where each vowel appears at least once. The vowels are ['a', 'e', 'i', 'o', 'u']. A substring is defined as a contiguous sequence of characters within the string.
Example
s = 'aeioaexaaeuiou'
There is a substring to the left that is
Asked in: MEESHO
Coding Wars
There are 'N' coders standing in a line, where i denotes the ith position of a coder with a rating of Ri. All ratings are distinct.
You have to form a team of 3 from amongst them with the condition:
Any three coders with positions (i, j, k) and ratings ("Ri< Rj< Rk" or "Ri > Rj > Rk") and(1 <= i < j < k <= N)
You have to find out how many such teams exist (1 coder can be part of m
Asked in: AMAZON MICROSOFT