C
C#10mo ago
AhmadHija

i need help

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