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 <iostream> | |
using namespace std; | |
void reverse(char* str){ | |
char* end = str; | |
char temp; | |
while(*end != '\0'){ | |
end++; | |
} | |
end--; |
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 UniqueChar { | |
public static void main( String[] args ) { | |
String[] strArray = { "abcdef", "dssfagagalglag" }; | |
for ( String str : strArray ) | |
System.out.println( isUniqueChar1( str ) ); | |
for ( String str : strArray ) | |
System.out.println( isUniqueChar2( str ) ); |
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 PermutationChar { | |
public static void main( String[] args ) { | |
String[] strArray = { "Guo Haoxuan", "Haoxuan Guo" }; | |
System.out.println( isPermutation ( strArray[0], strArray[1] ) ); | |
} | |
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.HashSet; | |
import java.util.Set; | |
public class FindDuplicateLL { | |
public static void main( String[] args ) { | |
LinkNode head = new LinkNode( 1 ); | |
head.append( new LinkNode( 2 ) ); | |
head.append( new LinkNode( 3 ) ); | |
head.append( new LinkNode( 1 ) ); |
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 KthToLast { | |
public static void main( String[] args ) { | |
LinkNode head = new LinkNode( 1 ); | |
head.append( new LinkNode( 10 ) ); | |
head.append( new LinkNode( 18 ) ); | |
head.append( new LinkNode( 5 ) ); | |
head.append( new LinkNode( 9 ) ); | |
head.append( new LinkNode( 100 ) ); | |
head.append( new LinkNode( 20 ) ); |
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 DeleteMiddleNode { | |
public static void main( String[] args ) { | |
LinkNode a = new LinkNode ( 5 ); | |
LinkNode b = new LinkNode ( 10 ); | |
LinkNode c = new LinkNode ( 9 ); | |
LinkNode d = new LinkNode ( 4 ); | |
LinkNode e = new LinkNode ( 7 ); | |
a.setNext( b ); |
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 BinarySearchTree { | |
private TreeNode root; | |
//private int height; | |
public BinarySearchTree() { | |
root = null; | |
} |
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 ArrayToBST { | |
public static void main( String[] args ) { | |
int[] x = { 9, 12, 14, 17, 19, 23, 50, 54, 67, 72, 76 }; | |
BinarySearchTree t = new BinarySearchTree(); | |
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 static int findMissing( int[] a ) { | |
Arrays.sort( a ); | |
if ( fetch( 0, 0 ) != 0 ) | |
return 0; | |
int max = ( int ) Math.log( n ) / Math.log( 2 ); | |
for ( int i = 1; i < n; i++ ) { | |
j = ( int ) Math.log( n ) / Math.log( i ); | |
if ( fetch( j, i ) != 1 ) | |
return i; | |
} |
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 BitSwap { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
int a = 0b10001111; | |
int b = a >> 1; |
OlderNewer