hotcoder
BAN USERvoid getPermutations(string[] input){
Hashmap hashMap = new Hashmap<String,List<String>();
for(int i=0; i< input.length(); i++){
String key = getKey(input[i]);
if(hashMap.contains(key){
hashMap.get(key).add(input[i]);
}
else{
hashMap.add(key,new List<String>(input[i]));
}
}
foreach( key in hashMap){
foreach(String in hashMap.getKey)
print(string+",")
print("\n");
}
}
pubic String getKey(String inpt){
int[] asciiAray;
int i=0;
foreach(char in inpt){
asciiAray[i++]=(int)char;
}
sort asciiarray;
String key;
foreach(int in asciiArray){
key+ =(char)int;
}
return key;
}
void printString(int num){
int N = num;
int n;
String result ="";
boolean flag = false;
if(N >= 26) flag = true;
while(N != 0){
n = N % 26;
N= N/26;
if(N == 0 && flag){
n = n-1;
}
result = getchar(n)+result;
}
System.out.println("Result is :"+result);
}
public char getchar(int n){
char c = (char)(65+n);
return c;
}
class Node {
int data;
Node nextNode;
public node(int data){
this.data= data;
}
public void setNode(Node next){
this.nextNode = next;
}
}
public static void main(String[] args){
int k= 10;
Node head = new Node(k); //first node
Node node = head;
for(i=0;i<6;i++){
Node next = new Node(i+k);//any value
node.setNode(next);
node=next;
}
}
Lol .. no there cant be a row with all 0's and column with all 1's in same matrix.. avoid jumping into coding..
- hotcoder September 11, 2013