Skip to content

Instantly share code, notes, and snippets.

View sunny73's full-sized avatar

YingL sunny73

View GitHub Profile
@sunny73
sunny73 / Multiply.cpp
Created March 21, 2019 11:09
大数乘法
#include<cstdio>
#include<cmath>
using namespace std;
#define SIGN(A) ((A > 0) ? 1 : -1)
int divideConquer(int X, int Y, int n){
int sign = SIGN(X) * SIGN(Y);
int x = abs(X);
int y = abs(Y);
@sunny73
sunny73 / Solution23.java
Created March 19, 2019 06:23
二叉树中和为某一值的路径
package com.Solutions;
import java.util.*;
import com.general.TreeNode;
import com.general.GenerateTree;
/**
* @program: work_practice
* @description: 二叉树中和为某一值的路径
@sunny73
sunny73 / Dijkstra.java
Created March 18, 2019 10:54
Dijkstra算法 输出路径
package other;
/*
*Dijkstra,最短路径算法
*/
public class Dijkstra {
public static final int M = -1;
static int[][] map = {
@sunny73
sunny73 / Solution22.java
Created March 10, 2019 11:35
判断是否后序遍历
/**
* @program: work_practice
* @description: 判断搜索二叉树的后续遍历是否正确
* @author: LiuYing
* @create: 2019-03-10 16:13
**/
public class Solution22 {
public boolean VerifySquenceOfBST(int[] sequence) {
int j = 0;
@sunny73
sunny73 / Solution17.java
Created March 10, 2019 05:44
二叉树得镜像
public void Mirror(TreeNode root) {
TreeNode temp =null;
if(root==null)
{
return;
}
if (root.left != null) { //这里要对root加以控制 否则 root.left会报错
Mirror(root.left);
@sunny73
sunny73 / Solution16.java
Created March 10, 2019 02:04
合并链表
import java.util.Stack;
/**
* @program: work_practice
* @description: 链表的连接
* @author: LiuYing
* @create: 2019-03-09 16:26
**/
public class Solution16 {
@sunny73
sunny73 / Solution15.java
Created March 8, 2019 18:31
倒置链表
/*
public class ListNode {
int val;
ListNode next = null;
ListNode(int val) {
this.val = val;
}
}*/
import java.util.Stack;
@sunny73
sunny73 / Solution12.java
Created March 8, 2019 16:40
二进制的问题
public class Solution {
public int NumberOf1(int n) {
int count = 0;
String str = Integer.toBinaryString(n);//注意这里求二进制的方法
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == '1') { //String 的元素采用的是这种方式
count++;
}
}
return count;
@sunny73
sunny73 / Solution11.java
Created March 8, 2019 10:32
矩形覆盖问题
/**
* @program: work_practice
* @description: 矩形覆盖问题
* @author: LiuYing
* @create: 2019-03-08 14:31
**/
public class Solution11 {
public int RectCover(int target) {
@sunny73
sunny73 / question7.java
Created March 7, 2019 06:31
斐波那契数列
public class Solution {
public int Fibonacci(int n) {
int a=1,b=1,c=0;
if(n<0){
return 0;
}else if(n==1||n==2){
return 1;
}else{
for (int i=3;i<=n;i++){
c=a+b;