LinkedList

LinkedList

->Linked List is a linear collection of  objects (called nodes) connected by the reference links.

->Program accesses a linked list via a reference to the first node in list.

->Program accesses a subsequent nodes via the reference link stored in the previous node.

->Reference in the last node of a list is set to null.

Source : from my lecturer slide, sir Jiwa Noris
 

Arrays.fill() Method

Arrays.fill() Method

Java.util.Arrays.fill(int[], int) Method

Arrays.fill() ini digunakan apabila kita ingin mengubah nilai didalam array yang kita buat dengan satu nilai. 
Di bawah ini adalah declaration untuk Arrays.fill()

public static void fill(int[] a, int val)
 
Dibawah ini adalah contoh program yang saya sediakan dengan menggunakan Arrays.fill().
Sumber : http://www.tutorialspoint.com/java/util/arrays_fill_int.htm
494 - Kindergarten Counting Game

494 - Kindergarten Counting Game

Kindergarten Counting Game 

Everybody sit down in a circle. Ok. Listen to me carefully.
``Woooooo, you scwewy wabbit!''
Now, could someone tell me how many words I just said?

Input and Output

Input to your program will consist of a series of lines, each line containing multiple words (at least one). A ``word'' is defined as a consecutive sequence of letters (upper and/or lower case).
Your program should output a word count for each line of input. Each word count should be printed on a separate line.

Sample Input

Meep Meep!
I tot I taw a putty tat.
I did! I did! I did taw a putty tat.
Shsssssssssh ... I am hunting wabbits. Heh Heh Heh Heh ...

Sample Output

2
7
10
9
 
 
10038 - Jolly Jumpers

10038 - Jolly Jumpers

Problem E: Jolly Jumpers

A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1. For instance,
1 4 2 3
is a jolly jumper, because the absolutes differences are 3, 2, and 1 respectively. The definition implies that any sequence of a single integer is a jolly jumper. You are to write a program to determine whether or not each of a number of sequences is a jolly jumper.

Input

Each line of input contains an integer n <= 3000 followed by n integers representing the sequence.

Output

For each line of input, generate a line of output saying "Jolly" or "Not jolly".

Sample Input

4 1 4 2 3
5 1 4 2 -1 6

Sample Output

Jolly
Not jolly
 
10107 - What is the Median?

10107 - What is the Median?

What is the Median? 

The Problem

Median plays an important role in the world of statistics. By definition, it is a value which divides an array into two equal parts. In this problem you are to determine the current median of some long integers. Suppose, we have five numbers {1,3,6,2,7}. In this case, 3 is the median as it has exactly two numbers on its each side. {1,2} and {6,7}.
If there are even number of values like {1,3,6,2,7,8}, only one value cannot split this array into equal two parts, so we consider the average of the middle values {3,6}. Thus, the median will be (3+6)/2 = 4.5. In this problem, you have to print only the integer part, not the fractional. As a result, according to this problem, the median will be 4!

Input 

The input file consists of series of integers X ( 0 <= X < 2^31 ) and total number of integers N is less than 10000. The numbers may have leading or trailing spaces.

Output 

For each input print the current value of the median.

Sample Input 

1
3
4
60
70
50
2

Sample Output 

1
2
3
3
4
27
4
 
Coding