C
C#9mo ago
AhmadHija

i need help

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