This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ispermutation | |
{ | |
public static void main(String[] args) | |
{ | |
String s = ""; | |
String t = ""; | |
boolean result = ispermutation(s,t); | |
System.out.println(result); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |