Day3. Start Algorithm
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace _88._Merge_Sorted_Array;
|
||||
namespace _88._Merge_Sorted_Array;
|
||||
|
||||
public class Solution
|
||||
{
|
||||
public void Merge(int[] nums1, int m, int[] a2, int n)
|
||||
{
|
||||
int[] a1 = new int[m];
|
||||
for(int i = 0; i < m; i++)
|
||||
for (int i = 0; i < m; i++)
|
||||
a1[i] = nums1[i];
|
||||
int resIndex = 0;
|
||||
int a1Index = 0, a2Index = 0;
|
||||
@@ -20,18 +16,18 @@ public class Solution
|
||||
int toWrite = 0;
|
||||
if (n1 != null && n2 != null)
|
||||
{
|
||||
toWrite = Math.Min(n1.Value,n2.Value);
|
||||
toWrite = Math.Min(n1.Value, n2.Value);
|
||||
if (n1 < n2)
|
||||
a1Index++;
|
||||
else
|
||||
a2Index++;
|
||||
}
|
||||
else if(n1!=null)
|
||||
else if (n1 != null)
|
||||
{
|
||||
toWrite = n1.Value;
|
||||
a1Index++;
|
||||
}
|
||||
else if(n2!=null)
|
||||
else if (n2 != null)
|
||||
{
|
||||
toWrite = n2.Value;
|
||||
a2Index++;
|
||||
|
||||
Reference in New Issue
Block a user