Skip to content

Instantly share code, notes, and snippets.

@asdw3276
asdw3276 / 1.4
Created June 18, 2014 18:53
1.4
public class replacespace{
public static void main(String[] args)
{
String teststring = "Mr John Smith sdfsf sdfs sssf d s";
char[] testchar = teststring.toCharArray();
char[] imput = new char[100];
for(int i = 0; i < testchar.length; i++)
imput[i] = testchar[i];
char[] result = replacespace(imput,testchar.length);
System.out.println(String.valueOf(result));
@asdw3276
asdw3276 / 1.6
Last active August 29, 2015 14:02
1.6
public class rotateimage{
public static void main(String[] args)
{
int[][] matrix ={{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16 ,17 ,18, 19, 20},{21 ,22 ,23 ,24, 25}};
matrix = rotateimage(matrix);
for(int i = 0; i < matrix.length; i++)
{
System.out.println();
for(int j = 0; j < matrix[0].length; j++)
{
@asdw3276
asdw3276 / 1.7
Created June 18, 2014 17:23
1.7
public class matrixsetzero{
public static void main(String[] args)
{
int[][] matrix = {{3,5,6,78,8},{1,2,4,5,6},{0,1,2,0,8},{0,0,1,1,1}};
matrix = matrixsetzero(matrix);
for(int i = 0; i < matrix.length; i++)
{
System.out.println();
for(int j = 0; j < matrix[0].length; j++)
{
@asdw3276
asdw3276 / 1.3
Created June 17, 2014 17:43
1.3
public class ispermutation
{
public static void main(String[] args)
{
String s = "";
String t = "";
boolean result = ispermutation(s,t);
System.out.println(result);
}
@asdw3276
asdw3276 / 1.2
Created June 17, 2014 17:16
1.2
public class reverse{
public static void main(String[] args)
{
String test = "abcdefgterhslaa";
String result = reverse(test);
System.out.println(result);
}
public static String reverse(String s)
{
@asdw3276
asdw3276 / 1.1
Last active August 29, 2015 14:02
1.1
public class isunique
{
public static void main(String[] args)
{
String s = "abcderfg";
boolean result = isunique(s);
System.out.println(result);
}
public static boolean isunique(String s)
@asdw3276
asdw3276 / 1.5
Last active August 29, 2015 14:02
1.5
public class stringcompress{
public static void main(String[] args)
{
String test = "aaabbccddaaaaaabba";
String result = compress(test);
System.out.println(result);
}
public static String compress(String s)