Java Linked List Basic

Oracle Doc, Tutorial Point The LinkedList class extends AbstractSequentialList and implements the List interface. It provides a linked-list data structure. java.util Class LinkedList<E>        java.lang.Object             java.util.AbstractCollection<E>                   java.util.AbstractList<E>                      … Continue reading Java Linked List Basic

Advertisements

CTCI: Given an input file with four billion integers, provide an algorithm to generate an integer which is not contained in the file.

Given an input file with four billion integers, provide an algorithm to generate an integer which is not contained in the file. Assume you have 1 GB of memory FOLLOW UP What if you have only 10 MB of memory? Solution There are a total of 2^32, or 4 billion, distinct integers possible. We have… Continue reading CTCI: Given an input file with four billion integers, provide an algorithm to generate an integer which is not contained in the file.

CTCI: Implement a jigsaw puzzle Design the data structures and explain an algorithm to solve the puzzle

First you need a "Piece" class to represent one piece of a puzzle. Each piece has four sides, each one with a unique outline which will only connect to one other piece. Edge sides have an "edge" outline. Each side also has a piece id attribute called "adjacent" to store the value of the piece… Continue reading CTCI: Implement a jigsaw puzzle Design the data structures and explain an algorithm to solve the puzzle

CTCI: Design the data structures for an online book reader system

The main entities will be - User Book Library Each user can have multiple book and each book can be subscribed to multiple user. Library maintains a list of all books. User - Each User will have few functions - addMemberShip(), renewMemberShip(), cancelMemberShip(), accessSubscribedBook(), readBook() Book - This can actually be split into two parts… Continue reading CTCI: Design the data structures for an online book reader system

Laravel: Lazy Load and Lazy Eager Loading

Laravel Lazy Load If you do not need to add additional constraints to an Eloquent relationship query, you may simply access the relationship as if it were a property. For example, continuing to use our User and Postexample models, we may access all of a user's posts like so: $user = App\User::find(1); foreach ($user->posts as $post) { //… Continue reading Laravel: Lazy Load and Lazy Eager Loading

Monitoring Processes with Supervisord

Supervisord is a simple and popular choice for process monitoring. Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems. Supervisord is a script monitoring tool. Below is the conf file which. [program:nodehook] command=/usr/bin/node /srv/http.js directory=/srv autostart=true autorestart=true startretries=3 stderr_logfile=/var/log/webhook/nodehook.err.log stdout_logfile=/var/log/webhook/nodehook.out.log user=www-data environment=SECRET_PASSPHRASE='this is secret',SECRET_TWO='another secret'… Continue reading Monitoring Processes with Supervisord