Pages

1/19/2014

UVA 10252 Common Permutation Java solution

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

/**
* @param args
* @throws IOException
* UVA 10252 - Common permutation solution
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader bReader = new   BufferedReader(new InputStreamReader(System.in));
StringBuffer sbr = new StringBuffer("");

String m;
while ((m=bReader.readLine())!=null) {
int [] c1 = new int[26];
int [] c2 = new int[26];
int [] cres = new int[26];

for (int i=0 ; i< m.length(); i++) {
if(m.charAt(i)>='a' && m.charAt(i)<='z' ){
                    c1[m.charAt(i)-97]++;
}
}
m=bReader.readLine();
for (int i=0 ; i< m.length(); i++) {
if(m.charAt(i)>='a' && m.charAt(i)<='z' ){
                    c2[m.charAt(i)-97]++;
}
}

for (int i=0 ;i<26;i++) {
int j = Math.min(c1[i],c2[i]);
for(int m1 =0; m1<j;m1++){
sbr.append((char)(97+i));
}
}
sbr.append("\n");

}
System.out.print(sbr);
}

}

UVA 1237 Solution

1/17/2014

Locked objects in oracle database

Following script will give the list of objects locked in a schema :

select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_name,b.object_type,a.locked_mode from
(select object_id, SESSION_ID, ORACLE_USERNAME, OS_USER_NAME, LOCKED_MODE from v$locked_object) a,
(select object_id, owner, object_name,object_type from dba_objects WHERE  owner = &owner) b
where a.object_id=b.object_id

12/13/2013

Code forces First submission

I was little late for the Div 2 contest today. This would have been my first div 2 contest. but i missed. Started practising. Came across 9C hexadecimal's number problem. It was a simple problem. It asked for counting the numbers within <= given number which are a vaild binay number. I arrived by taking the binary numbers from 1 and comparing representation in decimal with the given number. 

5/27/2013

UVA 10954

This problem uva 10954 can be easily solved using Priority queues in java. This is the first time i wrote code using a priority queue. It automatically sorts the elements added.

Here is my code