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.
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.
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 :)
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
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
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??
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...
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.
GO TO FULL VERSION