Measuring list performance
Comments (52)
- Popular
- New
- Old
You must be signed in to leave a comment
Krig Raseri
9 September 2022, 10:44
I interpreted this as the longest sequence of numbers, as in 4 was the most prevalent. It was not until I failed the check that it said UNBROKEN. I mean that's kinda what sequence means I suppose, just glossed over it.
I even did a cool thing that used the arraylist and a hashmap, where the key was the number and the value was Collections.frequency so it equaled the amount of times said number occurred. Then slap in Collections.max etc etc. I was so stoked for this too. but I played myself.
+1
Krig Raseri
9 September 2022, 10:44
Let this be a memorial.
RIP Krig's neat idea Sep. 2022.
+1
Anonymous #11003450
10 July 2022, 19:18
for the las one, I used a Set, 2 different arraylist. I was able to find what was required for the longest sequence, but it did not pass the check. Does the code have to match what the creators put in? There are different ways of getting the same result.
0
Pumbas
19 April 2022, 20:56
Last one was a great one, but i think you should have added the option to reorganize the ArrayList, because if you enter a random list, it will not give a correct result since he will check the next one and can be that is allways different, even is the Array as equal numbers... So first i added code to organize the ArrayList and then checked for equals. Still nice tho :)
0
cnsacramento
11 March 2022, 12:49
I really like so much the last practice. It's a good to remember that List doesn't work with primitive types so you have to remember how to compare two non-primitive types
+1
Jonaskinny Java Developer at Sandmedia
17 February 2022, 21:23
good test of our knowledge re comparing int vs Integer and auto-boxing ...
1==1 -> true
127==127 -> true
128==128 -> false (because we are storing Integer instead of int, so when we get passed byte max 127, we go to true reference comparisons, where @Object12345:value128==@Object54321:value128 -> false but @Object12345:value128.equals(@Object54321:value128) -> true
+1
Le Phan
5 February 2022, 15:22
Here is a short, simple but good surfed post for various methods using to measure the eslaped time.Baeldung.com/java-measure-elapsed-time
+2
Harvey Roberts
21 October 2021, 08:09
In the 10000 insertions and deletions you ask this:
5. The get10000(List list) method should call get 10,000 times on the list.
In your solution you have the number 5000. Where does that number come from??
0
John Squirrels Website Admin at CodeGym
21 October 2021, 09:56
5000 is just an example. You do not have to use this index, you can just use index i (for example, list.get(i);).
0
CaseyMacy
1 April 2022, 15:37
This is good to remember if you ever need to add items to the middle of a list; just specify the index where you want to insert items (index, item)
0
Franco Polizzi
25 August 2022, 17:52
Strange.. simple list.clear(); is fine for the remove10000 method.
0
Maryam Roudbari
17 September 2021, 05:39
can anyone give some hint about int x = list.size() / 2 in Time for 10,000 get calls?
0
Jonaskinny Java Developer at Sandmedia
17 February 2022, 21:24
red herring ...
0
sgubow
4 May 2021, 14:16
Is it just me or does it feel like they don't teach us most of how to solve these problems then I have to scratch my head at each one for 10 minutes without typing...
+4
Le Phan
5 February 2022, 10:51
Well, for saying things properly, we are learning from practice. In reality, there are cases whereas we have to solve unfamiliar problems. How you intend to solve them without much knowledge or even preparation? Thinking twice, trial-and-fail, asking for help, doing research for similar cases, etc., right? CodeGym studying process is the same like that. You are learning from reality, not from a textbook, man!
0
Jonaskinny Java Developer at Sandmedia
18 February 2022, 03:01
I think they are making sure you have seen what you need to know, gotten through the exercises (muscle memory), gotten a little lesson afterwards (once you did some self study to understand the exercise which is what happens at work all the time) to make sure you know what aspects to study should you wish to.
0
MCantu
8 February 2021, 02:34
So what is the difference between the following codes in a standard for loop:
list.get(i) //I know this holds the current element in the list.
list.get(i+1);
list.get(i -1)
list.get(i) + 1) //I think this one grabs the next element following the current element????
list.get(i) -1)
I am a little confused as to what they return.
Thanks.
0
MG
29 June 2021, 04:09
Hey!
list.get(i) == will give element at i th position
list.get(i+1) == will give element at (i+1) th position(next element)
list.get(i-1) == will give element at (i-1) th position(previous element)
list.get(i)+1 == here, you are adding an integer one to the element that is placed at i th position.
list.get(i)-1 == same as above, subtracting 1(provided values in the list are integers)
+2