Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Fix solution on problem 88 with js, fixs azl397985856#62

* Fix solution on problem 88, fixs azl397985856#62
  • Loading branch information
kant-li authored and azl397985856 committed Aug 4, 2019
1 parent 64c45ad commit 6b01607
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions problems/88.merge-sorted-array.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ function merge(nums1, nums2) {
* @return {void} Do not return anything, modify nums1 in-place instead.
*/
var merge = function(nums1, m, nums2, n) {
// 设置一个指针,指针初始化指向nums1的末尾
// 设置一个指针,指针初始化指向nums1的末尾(根据#62,应该是index为 m+n-1 的位置,因为nums1的长度有可能更长)
// 然后不断左移指针更新元素
let current = nums1.length - 1;
let current = m + n - 1;

while (current >= 0) {
// 没必要继续了
Expand Down Expand Up @@ -181,7 +181,7 @@ C++ code:
class Solution {
public:
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
int current = nums1.size()- 1;
int current = m + n - 1;
while (current >= 0) {
if (n == 0) return;
if (m < 1) {
Expand Down

0 comments on commit 6b01607

Please sign in to comment.