# Coding Interviews: Searching and Sorting

Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties:

Integers in each row are sorted in ascending from left to right.

Integers in each column are sorted in ascending from top to bottom.

Given two positive integers m and n which are the height and width of a **0-indexed** 2D-array board, a pair of positive integers (r, c) which is the starting position of the knight on the board.

Your task is to find an order of movements for the knight, in a manner that every cell of the board gets visited **exactly** once (the starting cell is considered visited and you **shouldn't** visit it again).

Return *the array* board *in which the cells' values show the order of visiting the cell starting from 0 (the initial place of the knight).*

Note that a **knight** can **move** from cell (r1, c1) to cell (r2, c2) if 0 <= r2 <= m - 1 and 0 <= c2 <= n - 1 and min(abs(r1 - r2), abs(c1 - c2)) = 1 and max(abs(r1 - r2), abs(c1 - c2)) = 2.

People are waiting in line (British english: "queue" not the data structure "queue"). You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki] represents the ith person of height hi with **exactly** ki other people in front who have a height greater than or equal to hi.

Reconstruct and return *the queue that is represented by the input array *people. The returned queue should be formatted as an array queue, where queue[j] = [hj, kj] is the attributes of the jth person in the queue (queue[0] is the person at the front of the queue).

Given an integer array nums and an integer k, return *the* kth *largest element in the array*.

Note that it is the kth largest element in the sorted order, not the kth distinct element.

Given an integer array nums, find the subarray with the largest sum, and return its sum.

Given an array of integers nums and an integer target, return *indices of the two numbers such that they add up to **target*.

You may assume that each input would have **exactly**** one solution**, and you may not use the *same* element twice.

You can return the answer in any order.