-
PROHARDVER!

Új hozzászólás Aktív témák
-
Chesterfield
őstag
Erre a feladatra tudtok hatékonyabb algoritmust?
Write a function that, when passed a list and a target sum, returns two distinct zero-based indices of any two of the numbers, whose sum is equal to the target sum. If there are no two numbers, the function should return null.
For example, FindTwoSum(new List<int>() { 3, 1, 5, 7, 5, 9 }, 10) should return a Tuple<int, int> containing any of the following pairs of indices:
0 and 3 (or 3 and 0) as 3 + 7 = 10
1 and 5 (or 5 and 1) as 1 + 9 = 10
2 and 4 (or 4 and 2) as 5 + 5 = 10public static Tuple<int, int> FindTwoSum(IList<int> list, int sum)
{
for (int i = 0; i < list.Count; i++)
{
for (int j = i + 1; j < list.Count; j++)
{
if (list[i] + list[j] == sum)
{
return Tuple.Create(i, j);
}
}
}
return null;
}azt mondja a kiértékelő, hogy Performance testen ez elbukik.
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
- HP ZBook 17 G6 i7-9850H / 64GB / 512GB SSD / Quadro RTX 3000 / Hun bill / Újszerű állapotú
- DJI Mini 4 pro - Fly More Combo - RC2 drón szett - 500m magasság, C1, kevés repülés
- DJI Mini 4 pro - Fly More Combo - RC2 drón szett - 500m magasság, C1, Care Refresh, PL Filter
- Nintendo Switch 2 // Számla + Garancia //
- Gyerek kerékpár 12 Kék színű, tanulókerékkel, kosárral (2 4 éves korosztálynak)
- Bomba ár! Dell Vostro 3560 - i3-3120M I 8GB I 320GB I DVDRW I 15,6" HD I HDMI I Cam I Garancia!
- 121 - Lenovo Legion Pro 5 (16ARX8) - AMD Ryzen 7 7745HX, RTX 4070 - 4 év garancia
- Ravpower 6000 mAh-s mégis pici powerbank eladó
- ÁRGARANCIA!Épített KomPhone Ryzen 7 5700X 16/32/64GB RAM RX 9060 XT 8GB GAMER PC termékbeszámítással
- Xiaomi 14T Pro 5G 512GB, Kártyafüggetlen, 1 Év Garanciával
Állásajánlatok
Cég: NetGo.hu Kft.
Város: Gödöllő
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest




