Archive for the ‘Uncategorized’ Category.
November 11, 2009, 9:09 pm
Given a sorted array rotated n times. Find the number of right side rotations performed on the array.
Example:
input: 678912345
expected output: 4 (rotating 123456789 4 times we will get the input)
November 11, 2009, 9:00 pm
Given a document and a query of K words, how do u find the smallest window that covers all the words at least once in that document?
November 10, 2009, 9:08 am
Given 2 linked lists merged at some point in the form of a ‘Y’. Find the intersection point
November 7, 2009, 11:48 pm
You have 50,000 html files, some of which contain phone numbers. How would you create a list of all the files which contain phone numbers?
Note : Phone numbers are in format ddd[- OR ' ']ddd[- OR ' ']dddd
November 7, 2009, 9:54 pm
- Ensure a class has only one instance and provides a global point of access to it
- Useful when exactly one instance of a class is needed to coordinate actions
- Abstract Factory,Prototype and Builder can use Singleton in their implementation
- Facade objects and State objects are often SIngletons
- Often preffered as global variables -Provides OO Design scope,Allows lazy initialization or dynamic change in behaviour
Continue reading ‘Singleton Design Pattern implementation in Java’ »
November 5, 2009, 11:31 am
November 4, 2009, 10:56 am
A log file is of the following format
sessionid ipaddress
1234 127.0.0.1
4567 127.0.0.1
Find the list of top 10 IP Addresses that have the most log entries.
October 29, 2009, 11:50 am
searchJars.sh :
-----------------------------------------------------
#!/bin/bash
while getopts "n:il" optionName; do
case "$optionName" in
i) case_sensitive_op=-i;;
l) long_format=Y;;
n) search_expr="$OPTARG";;
[?]) echo "Usage: searchJars [-i] [-l] -n ";exit 1;;
esac
done
if [ -z $search_expr ]
then
echo "Usage: searchJars [-i] [-l] -n ";
exit 1;
fi
if [ $# -lt 1 ]
then
echo "Usage: searchJars [-i] [-l] -n ";
exit 1;
fi
REG_EXPR="$search_expr"
for i in `find . -name "*jar"`
do
jar tvf $i 2> /dev/null | grep $case_sensitive_op $REG_EXPR > /dev/null
if [ $? == 0 ]
then
echo $i
if [ "$long_format" = "Y" ]
then
jar tvf $i | grep $case_sensitive_op $REG_EXPR | awk '{ print " "$8}'
echo "-----------------------------------------------------"
fi
fi
done
-----------------------------------------------------
Usage:
Usage: searchJars [-i] [-l] -n CLASS_NAME_OR_EXPRESSION
October 28, 2009, 7:54 am
October 28, 2009, 7:50 am