The basic level problem contains the variation of array with sorting / dividing. With the knowledge of C# and other programming skills, I could write the answer of problem. What I solved on today could be summarized with the list.
By using the for
, List
and some logics, I could write the answer like that.
int[] Solution(int[] input_arr, int n)
{
for(...)
{
...
}
}
After submitting my own answer, the other solutions can be seen. Using the features of array, there were more compact, easier to understand methods.
The one of those method is the function of array.
int[] result = new int[<number of array>];
Array.Copy(<src array>, <starting idx or src>, <destination>, <starting idx of destination>,<number>);
Facilitating the Array.Copy
method makes my understand easier. Keeping that on my TIL, I faced the other problems.
There is other cases which invokes Array
in the solution with lamda equation.
In the problem that requires the index of negative element, the simple answer is
Array.FindIndex(<input array>,f => f<0)
Which use the application of anomynous method f => f<0
. We can understand the operation. searching the element one by one, and check the negative.
Finally, I have learned the convertion to use the method in List. The problem asks us to make array starting from the index of mediator.
<input_array>.Skip(n - 1).ToArray();
The solution say that It will skip the first several element and make it to new array.
I have to learn more about the intrinsic methods.