db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Db-derby Wiki] Update of "Sreedish" by Sreedish
Date Fri, 23 Mar 2012 06:58:55 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Db-derby Wiki" for change notification.

The "Sreedish" page has been changed by Sreedish:
http://wiki.apache.org/db-derby/Sreedish?action=diff&rev1=1&rev2=2

+ import java.util.Random;
- ##master-page:HomepageTemplate
- #format wiki
- #language en
- == @``ME@ ==
  
+ public class Anagram {
- Email: <<MailTo(you AT SPAMFREE example DOT com)>>
- ## You can even more obfuscate your email address by adding more uppercase letters followed
by a leading and trailing blank.
  
- ...
+    
+     public static boolean findAnagram(String str1,String str2) {
+ 	
+ 	int i , j, k;
+ 	int flagstr[] = new int[str1.length()];
+ 	
+ 	for(i=0;i<str2.length();i++) flagstr[i]=0;
+ 	
+ 	if(str1.length() != str2.length()) return false;
  
- ----
- CategoryHomepage
+ 	for( j=0;j<str1.length();j++)
+ 	{	  
+ 	 	for( k=0;(k<str2.length()) ; k++)
+ 		{
+ 			if(str1.charAt(j)==str2.charAt(k)&& (flagstr[k]==0)) break;
+ 		}
+ 		if((j<str1.length()) &&(k<str2.length()))	
+ 		if( (str1.charAt(j)==str2.charAt(k)))
+ 		flagstr[k]=1;
+   	}
+ 	for(i=0;i<str1.length();i++) System.out.println(flagstr[i]+" ");
+ 	for(i=0;i<str1.length();i++) if(flagstr[i]==0) return false;
+        
+ 	return true;
+     }
  
+     
+     public static void main(String[] args) {
+       
+         System.out.println(findAnagram("hello","oelll"));
+     }
+ }
+ 

Mime
View raw message