44 Replies
hi
@leowest
you remember me ?
you helped me solve a question like a month ago
i need help again please
<:
Just ask the question
i have 2 arrays and i need to return a new array without the repeated numbers and it needs to be Arranged in ascending order
array without repeated numbers, so distinct numbers?
yea something like that
there are plenty of ways to do that. What have you tried?
yea i tried and i solved a similar question with only one array
but i cant figure out how to do this one
Show us your best attempt then
where should i send it ?
Here?
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/BlazeBin - zpkdcderwvdz
A tool for sharing your source code with the world!
i did a method that checks if the number is repeated and another one that counts the array length
but i can figure out how to continue
uh
this is a mess
CheckArray
? GetLength
?
GetLength does not return the length of the passed array, so.. what does it do?
why is it called GetLength
when it doesnt get the length?it finds the length without the repeated number
for one array
jfc
do you know about data structures?
what does that mean
Like, you clearly know array
but have you ever heard of a
List
or a Set
?can you give me example maybe i know the code but not the name
The name is the code in this case
var list = new List<int>();
var set = new HashSet<int>();
we didn't learn that
Ah, so we're working within the confines of it being a school project, gotcha
cause your code is doing some pretty weird things
you're looping over the entire array, for each value in the array
yea (:
you mean the check array method
yeah. that loops over the entire array
and you call that from GetLength
which also loops over the entire array
how about we plan this out a bit
Given any two arrays, what is the maximum length of the "output" array?
ie the one with only distinct numbers
i didn't understand tbh
if I pass two arrays to you,
a
and b
what is the maxmimum length of the desired output array c
that contains only the distinct numbers from a
and b
?a+b
yes
so we can skip the entire
getLength
bitand what should we do
but why should we skip it ?
ok think about how you would solve this on paper instead then
I give you two lists of numbers
I want you to give me all the distinct numbers
how would you do that, with pen and paper?
just write the numbers ?
well no, you failed - you included the duplicate numbers
try again
how did i fail bruv just write the numbers without repeating them
dont be stupid
or just using eraser and deleting them
you have to explain HOW you would go about doing that
thats obviously the entire exercise here
First let me ask you general question can we delete or remove arrays bound
?
what do you mean by that
arrays are fixed size
wait wait
we should
after they are created, their lengths cant be changed
you can however create a new array with a different length and copy stuff over
soo we create a new array
and check both of the other arrays
brb 30 min
yes, of course