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 boolean uniquechar(String str) { | |
if(str.length()>256) | |
return false; | |
if(str.length()=0) | |
return true; | |
boolean[] charset=new boolean[256]; | |
for(int i=0;i<str.length;i++){ | |
int val=str.charat(i); | |
if(char_set[val]){ |
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
#include <studio.h> | |
void swap(char* a, char* b) | |
void reserve(char* str) | |
void swap(char*a char*b){ | |
char* a=t; | |
a=b; | |
b=t; | |
} | |
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
package isPermutation; | |
import java.util.Arrays; | |
public class isPermutation{ | |
public static void main (String[] args) { | |
String s="good"; | |
String t="adog";/*give s,t*/ | |
System.out.println(isPerm(s,t)); | |
} |
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
package replaceSpace; | |
public class replaceSpace { | |
public static void main(String[] args){ | |
String s="My dog is maotou"; | |
String t=add(s); | |
System.out.println(s); | |
System.out.println(t); | |
} |
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
import java.util.*; | |
public class compBetter { | |
public static String compBet (String s){ | |
int size=countCompression(s); | |
if(size>s.length()){ | |
return 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
package rotateMatrix; | |
import java.util.*; | |
public class rotateMatrix { | |
public static int[][] rotateMat(int[][] matrix){ | |
int n=matrix.length; | |
for(int row=0;row<n/2;row++){ | |
int first=row; | |
int last=n-1-row; |
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
package setZero; | |
public class setZero { | |
public static int[][] setZeros(int[] [] matrix){ | |
boolean[] row=new boolean[matrix.length]; | |
boolean[] column=new boolean[matrix[0].length]; | |
for(int i=0;i<matrix.length;i++){ | |
for(int j=0;j<matrix[0].length;j++){ | |
if(matrix[i][j]==0){ |
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
package deleteDuplicates; | |
import java.awt.List; | |
import java.util.*; | |
public class deleteDuplicates { |
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
package isRotation; | |
import java.util.Arrays; | |
public class isRotation{ | |
public static boolean isRotation(String s1, String s2) { | |
int len=s1.length();{ | |
if(len==s2.length()&&len>0) | |
{ | |
String s1s1=s1+s1; | |
return isSubstring(s1s1,s2); |
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
package nthToLast; | |
import java.awt.List; | |
import java.util.*; | |
public class nthToLast { | |
public static <ListNode> int nthToL(ListNode head, int k){ | |
if(head==null){ | |
return 0; |
OlderNewer