i need help

i need help solving this question
44 Replies
ahmadhija🌵
ahmadhija🌵4mo ago
hi @leowest you remember me ? you helped me solve a question like a month ago i need help again please <:
Angius
Angius4mo ago
Just ask the question
ahmadhija🌵
ahmadhija🌵4mo ago
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
Pobiega
Pobiega4mo ago
array without repeated numbers, so distinct numbers?
ahmadhija🌵
ahmadhija🌵4mo ago
yea something like that
Pobiega
Pobiega4mo ago
there are plenty of ways to do that. What have you tried?
ahmadhija🌵
ahmadhija🌵4mo ago
yea i tried and i solved a similar question with only one array but i cant figure out how to do this one
Pobiega
Pobiega4mo ago
Show us your best attempt then
ahmadhija🌵
ahmadhija🌵4mo ago
where should i send it ?
Pobiega
Pobiega4mo ago
Here? $code
MODiX
MODiX4mo ago
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/
ahmadhija🌵
ahmadhija🌵4mo ago
BlazeBin - zpkdcderwvdz
A tool for sharing your source code with the world!
ahmadhija🌵
ahmadhija🌵4mo ago
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
Pobiega
Pobiega4mo ago
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?
ahmadhija🌵
ahmadhija🌵4mo ago
it finds the length without the repeated number for one array
Pobiega
Pobiega4mo ago
jfc do you know about data structures?
ahmadhija🌵
ahmadhija🌵4mo ago
what does that mean
Pobiega
Pobiega4mo ago
Like, you clearly know array but have you ever heard of a List or a Set?
ahmadhija🌵
ahmadhija🌵4mo ago
can you give me example maybe i know the code but not the name
Angius
Angius4mo ago
The name is the code in this case var list = new List<int>();
Pobiega
Pobiega4mo ago
var set = new HashSet<int>();
ahmadhija🌵
ahmadhija🌵4mo ago
we didn't learn that
Angius
Angius4mo ago
Ah, so we're working within the confines of it being a school project, gotcha
Pobiega
Pobiega4mo ago
cause your code is doing some pretty weird things you're looping over the entire array, for each value in the array
ahmadhija🌵
ahmadhija🌵4mo ago
yea (: you mean the check array method
Pobiega
Pobiega4mo ago
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
ahmadhija🌵
ahmadhija🌵4mo ago
i didn't understand tbh
Pobiega
Pobiega4mo ago
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?
ahmadhija🌵
ahmadhija🌵4mo ago
a+b
Pobiega
Pobiega4mo ago
yes so we can skip the entire getLength bit
ahmadhija🌵
ahmadhija🌵4mo ago
and what should we do but why should we skip it ?
Pobiega
Pobiega4mo ago
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?
ahmadhija🌵
ahmadhija🌵4mo ago
just write the numbers ?
Pobiega
Pobiega4mo ago
well no, you failed - you included the duplicate numbers try again
ahmadhija🌵
ahmadhija🌵4mo ago
how did i fail bruv just write the numbers without repeating them
Pobiega
Pobiega4mo ago
dont be stupid
ahmadhija🌵
ahmadhija🌵4mo ago
or just using eraser and deleting them
Pobiega
Pobiega4mo ago
you have to explain HOW you would go about doing that thats obviously the entire exercise here
ahmadhija🌵
ahmadhija🌵4mo ago
First let me ask you general question can we delete or remove arrays bound
Pobiega
Pobiega4mo ago
? what do you mean by that arrays are fixed size
ahmadhija🌵
ahmadhija🌵4mo ago
wait wait we should
Pobiega
Pobiega4mo ago
after they are created, their lengths cant be changed you can however create a new array with a different length and copy stuff over
ahmadhija🌵
ahmadhija🌵4mo ago
soo we create a new array and check both of the other arrays
Pobiega
Pobiega4mo ago
brb 30 min yes, of course