GithubHelp home page GithubHelp logo

java-loop-probs's People

Contributors

mahiki avatar

Watchers

 avatar

java-loop-probs's Issues

generic version of bubble sort

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.

deduplicate array of objects

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?

  1. a == b is true if the reference is the same (ie the same object)
  2. Testing each element against every other is N^2.
  3. Emre's interlocutor taught him to add a property to each object...?

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.

reverse a linked list in-place

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.