2019-04-22  237 views 评论

# [leetcode]题目解析（190422）

标签：

## unique path

### 题目描述

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).How many possible unique paths are there?

Above is a 3 x 7 grid. How many possible unique paths are there?Note: m and n will be at most 100.

## n queens ii

### 题目描述

Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.

## merge sorted array

### 题目描述

Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:
You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B are mand n respectively.

### 题目解析

• 原来的A和B都已经完整插入到A中，即x1=-1且x2=-1。
• 原来B已经插入完毕了但是A还没有，即x2=-1且x1>=0，此时A剩下的数字都在正确的位置，不需要再排序了。
• 原来的A插入完毕了，B还没有，即x1=-1且x2>=0，那就直接把B插入到剩下的位置即可。