Skip to content

[ARCHIVED] A two common coding challenges: reverse string, and a FIFO queue

Notifications You must be signed in to change notification settings

BitResolution/jpm-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

jpm-utils

A couple of solutions to common programming challenges:

  1. Implement a method which reverses a string (e.g., reverse("abc") returns "cba") - see StringUtils

  2. Implement a blocking FIFO queue - see FifoQueue, ArrayListBlockingFifoQueue and LinkedListBlockingFifoQueue

    • The queue implementation should implement the following interface:
    interface FIFOQueue {
        public void enqueue(Object obj);
        public Object dequeue();
    }
    • The queue must be thread-safe to >2 threads accessing it concurrently.
    • The queue must have a size, which equals the number of objects currently enqueued.
    • The queue must have a finite capacity, meaninng a maximum number of objects that can ever be enqueued at a single time.
    • When attempting to enqueue an object when the size of the queue is equal to or greater than the capacity, the enqueue operation should block until space becomes available within the queue.
    • When attempting to dequeue an object when the size of the queue is zero (the queue is empty), the dequeue operation should block until an object becomes available.
    • The implementation should implement the internal object storage using a List implementation
    • Use of the java.util.concurrent package is not allowed

About

[ARCHIVED] A two common coding challenges: reverse string, and a FIFO queue

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages