saksharhere
BAN USERprivate static void printZigZag(int[][] A) {
boolean zig = true;
int j=0;
for(int i=0;i<A.length;i++){
for(int k=0;k<A[0].length;k++)
if(zig){
System.out.print(A[i][j++]+ " ");
}else{
System.out.print(A[i][j--]+" ");
}
if(zig)
j--; else j++;
zig= !zig;
System.out.println();
}
}
HashTable, and a wordcount variable,
Key -> Time
Value -> WordCount
whenever the new word is encountered, wordcount is incremented and pushed into HashMap.
For example ,
Seconds , words
0 -> nothing wordcount - 0
10 -> "This" wordcount -1
20 -> "This is" wordcount -2
30 -> "This is a" wordcount - 3
43 -> "This is a stream" wordcount - 4
HashMap
Key | Value
10 - 1
20 - 2
30 - 3
43 - 4
<pre lang="java" line="1" title="CodeMonkey67975" class="run-this">/* The class name doesn't have to be Main, as long as the class is not public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
String s;
while (!(s=r.readLine()).startsWith("42")) System.out.println(s);
}
}
</pre><pre title="CodeMonkey67975" input="yes">bolo boss</pre>
What was the code about?
- saksharhere October 31, 2010