Skip to content

Instantly share code, notes, and snippets.

View hilda8519's full-sized avatar
🎯
Focusing

hilda8519's GitHub hilda8519

🎯
Focusing
  • san jose,ca,usa
View GitHub Profile
@hilda8519
hilda8519 / week2 AcitivityTwo
Created January 27, 2015 06:58
Programming-Mobile-Applications-for-Android-Handheld-Systems week2 AcitivityTwo
package course.labs.activitylab;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
@hilda8519
hilda8519 / gist:21a3a31a4e7fa26e5706
Created January 27, 2015 06:49
Programming-Mobile-Applications-for-Android-Handheld-Systems week2 AcitivityOne
package course.labs.activitylab;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class Solution {
public int minCut(String s) {
int n = s.length();
boolean[][] isPalindrome = new boolean[n][n];
for (int i = 0; i < n; i++)
isPalindrome[i][i] = true;
for (int i = n - 1; i >= 0; i--) {
for (int j = i + 1; j < n; j++) {
if (s.charAt(i) == s.charAt(j)) {
if (j - i < 2 || isPalindrome[i + 1][j - 1])
package numberofways;
public class numberofways {
public static int numberways(int n){
if(n<0){
return 0;
}
if(n==0){
return -1;
}
public class Question5_8 {
public void drawHorizontalLine(byte[] screen, int width, int x1, int x2, int y) {
int height = screen.length / (width / 8);
if (y < 0 || y >= height || x1 < 0 || x1 >= screen.length * 8 || x2 < 0 || x2 >= screen.length * 8) {
return;
}
int idx = y * (width / 8);
int idx1 = idx + (x1 / 8);
int idx2 = idx + (x2 / 8);
public class SwapBits {
public static int swap(int n) {
int EvenBits = 0xAAAAAAAA & n;
int OddBits = 0x55555555 & n;
return( (OddBits << 1) | (EvenBits >> 1) );
}
public static void main(String args[]){
int test = 0b0101110011;
System.out.println(Integer.toBinaryString(swap(test)));
public class Q55{
public static void main(String[] args){
int test1= 0b100111010110;
int test2= 0b011001000101;
System.out.println(numberOfCovert(test1,test2));
}
static int bitSwapRequired(int a, int b){
int count=0;
int c=a^b;
for(c=!0;c=>1){
import java.util.*;
public class Q54 {
public static void main(String[] args){
System.out.println(match2Number(2,4));
}
static boolean match2Number(int N,int Number M) {
M=N-1;
public class Q52 {
public static void main(String[] args){
System.out.println(printBinary(0.111111));
System.out.println(printBinary(0.8));
}
static String printBinary(double num){
if(num>1 || num<0)
return "ERROR";
public class BitManipulaation {
public static int rewrite(int n, int m,int i, int j){
//to all ones: 11111111111111111111111111111111
int allOne = ~0;
//all ones before j, then 0s
int left = allOne << (j + 1);
//all 0s before i, then 1s
int right = ((1 << i) - 1);
//all ones, but range i - j are 0s