mahiki / java-loop-probs Goto Github PK
View Code? Open in Web Editor NEWa series of problems like in an SDE loop
a series of problems like in an SDE loop
good practice for generics. this is a generic static method, it takes an array of any type of item.
sortArray<T>(T[] array){...}
I think.
the method has to implement Comparable
or something, comparison/equality of generic items must be defined.
Learn how great trace is for understanding what you built.
Try a recursive method that reverses a pointer, then calls itself.
Emre had this in an interview.
An array of objects contain duplicate items (object references that are pointing to the same object).
Can you quickly O(N) discover and remove the duplicates?
Original Problem Spec
Using whatever resources you want, please write a JavaScript function that takes an array of objects and returns a unique-ified version of the same array.
To be clear, there could be objects that are copies or duplicates of other objects, but the goal is to just remove the duplicates, not the copies. Duplicates means references to the same object in memory. Copies means different objects in memory with the same properties. The level of nesting in the object should not matter.
There are multiple ways to solve this, but the goal is to solve it with an algorithm that is as fast as possible.
How many palindrome numbers are there from 0 to 2000. Can you do that in your head?
http://stackoverflow.com/questions/6401289/how-to-find-out-all-palindromic-numbers
start with integers.
you can build it to include generics, which then have a comparable interface.
small change, to accept list items of any type
How Java handles references to object is hugely important. Work through the examples until you understand the implications and the bugs that can come from this feature.
Some links
Method arguments are passed by value (which are references) java world explanation
Stackoverflow
Do a tutorial on Collections, and some exercises.
take a linked list of arbitrary length, reverse it's order.
not by duplicating, just manipulating node pointers with a few variables maybe.
for starters assume simple data type, finish with Generic
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.