Posts

Showing posts from August 18, 2013

To print longest pattern sequence

Problem: Write a program to print longest pattern sequence. e.g. Input String str="123424861234567"; Patterns are "1234","2486","1234567" with common difference 1,2,1 respectively.So being the longest third pattern i.e.  "1234567" is the output. package assignment1; /**  * @author snlkjha  */ public class Str {         public static void lognest_str_pattern(char s[]){                 int count1[]=new int[5],count2[]=new int[5],t=0,max=0,i,j;    // Variable declaration         for(i=0;i<s.length;i=i+j+1){             j=0;             while((i+j+1)<s.length && (s[i+j+1]-'0')-(s[i+j]-'0')==((s[i+1]-'0')-(s[i]-'0')))   j++;             count2[t]=i+j+1;             count1[t]=j+1;             max=count1[m...

How to install java in ubuntu operating system

                                            Open terminal On the command line, type: $   sudo apt-get install openjdk-7-jre ( The   openjdk-7-jre   package contains just the Java Runtime Environment. ) If you want to develop Java programs then install the   openjdk-7-jdk   package by typing : sudo apt-get install openjdk-7-jdk .