1. Knight Probability in Chessboard Calculate the probability that a knight remains on an N x N chessboard after making K moves. Initially, the knight is placed at a given position on the board. It can move in any of the 8 directions it is allowed to on a chessboard. The knight's potential moves from any position (i, j) are: (i + 2, j + 1), (i + 2, j - 1), (i - 2, j + 1), (i - 2, j - 1), (i + 1, j + 2), (i + 1, j - 2), (i - 1, j + 2), and (i - 1, j - 2). Input: The first line contains an integer, 'T', denoting the number of test cases. Each test case starts with two integers, 'N' and 'K', which denote the chessboard's dimension and the number of moves the knight must make. The next line of each test case contains two integers, 'Sx' and 'Sy', representing the knight's initial position. Output: For each test case, print the probability that the knight remains on the chessboard after all moves. Ensure the output is accurate to six decimal places. Example: Input: 28 30 010 75 5 Output: 0.1250000.981250 Constraints: 1 <= T <= 5 0 <= N <= 30 0 <= K <= 500 0 <= Sx, Sy <= N - 1 Time Limit: 1 sec. Note: Consider all possible sequences of the knight's moves to determine its likelihood of staying on the board.
2. Minimum Distinct Labels Problem Statement You are given N boxes on a table, each with an integer label. The labels of these boxes are provided in an array ARR. Your task is to remove exactly M boxes such that the number of distinct labels left on the table is minimized. Example: Input: M = 2ARR = [3, 4, 5, 3] Output: 1 Explanation: If you remove the second and third boxes, all remaining boxes will have the label 3. Thus, the minimum distinct labels left is 1. Constraints: 1 <= T <= 10 1 <= N <= 104 0 <= M <= N 1 <= ARR[i] <= 109 Time Limit: 1 sec Input: The first line contains an integer T, the number of test cases. For each test case, the first line contains two integers, N (number of boxes) and M (number of boxes to be removed).The second line contains N space-separated integers representing the labels of the boxes. Output: For each test case, output the minimum number of distinct labels left after removing exactly M boxes. Note: You do not need to print anything. Just implement the provided function to return the result.
3. Given a binary tree, find the length of the diameter of the tree. The diameter of a tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
4. Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between).
5. Reverse nodes in k groups, sum of right leaf nodes
Browse through a variety of job opportunities tailored to your skills and preferences. Filter by location, experience, salary, and more to find your perfect fit.
We have sent an OTP to your contact. Please enter it below to verify.