All Posts
Leetcode 1222: Queens That Can Attack the King
On an 8x8 chessboard, there are multiple black queens and one white king. You are given the positions of the black queens and the white king. Your task is to find all the black queens that can directly attack the white king. A queen can attack the king if they share the same row, column, or diagonal.
Leetcode 1389: Create Target Array in the Given Order
Given two arrays of integers nums and index, the task is to create a target array by inserting elements of nums at the positions specified by index. After processing all elements, return the target array.
Leetcode 1409: Queries on a Permutation With Key
You are given a list of positive integers called queries
, each between 1 and m
. You need to process each element in queries
sequentially according to the following rules:
- Initially, the permutation
P
is[1, 2, 3, ..., m]
. - For each
queries[i]
, find the index ofqueries[i]
in the permutationP
. - After locating
queries[i]
inP
, move it to the beginning of the list. - Return the list of indices (positions) for each element in
queries
as they are processed.