Ready to create a quiz? Use Canvas to test your knowledge with a custom quiz Get started
Use the Java Standard Library: Don't reinvent the wheel. Know your way around Java Platform SE 8 or higher, especially the Collections API.
"Your code passed the test cases," Sarah continued, "but we’re looking for optimization. The brute force is $O(n^2)$. Can you improve it?"
public static int removeDuplicates(int[] a)
if (a.length==0) return 0;
int write = 1;
for (int read=1; read<a.length; read++)
if (a[read] != a[read-1]) a[write++] = a[read];Ready to create a quiz? Use Canvas to test your knowledge with a custom quiz Get started
Use the Java Standard Library: Don't reinvent the wheel. Know your way around Java Platform SE 8 or higher, especially the Collections API.
"Your code passed the test cases," Sarah continued, "but we’re looking for optimization. The brute force is $O(n^2)$. Can you improve it?"
public static int removeDuplicates(int[] a)
if (a.length==0) return 0;
int write = 1;
for (int read=1; read<a.length; read++)
if (a[read] != a[read-1]) a[write++] = a[read];

Interesting content fromCanary Labs

For more tips and tricks on starting or mastering Canary, make sure to check out their Help Center. You can talk to the community to ask questions, find solutions, and offer feedback, consult the knowledge base for a fast answer, or get on-demand learnings and webinars from the Canary Academy. testdome java questions and answers

It's time to start truly understanding your time-series data.