This file contains hidden or 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<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); |
This file contains hidden or 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 com.Solutions; | |
| import java.util.*; | |
| import com.general.TreeNode; | |
| import com.general.GenerateTree; | |
| /** | |
| * @program: work_practice | |
| * @description: 二叉树中和为某一值的路径 |
This file contains hidden or 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 other; | |
| /* | |
| *Dijkstra,最短路径算法 | |
| */ | |
| public class Dijkstra { | |
| public static final int M = -1; | |
| static int[][] map = { |
This file contains hidden or 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
| /** | |
| * @program: work_practice | |
| * @description: 判断搜索二叉树的后续遍历是否正确 | |
| * @author: LiuYing | |
| * @create: 2019-03-10 16:13 | |
| **/ | |
| public class Solution22 { | |
| public boolean VerifySquenceOfBST(int[] sequence) { | |
| int j = 0; |
This file contains hidden or 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 void Mirror(TreeNode root) { | |
| TreeNode temp =null; | |
| if(root==null) | |
| { | |
| return; | |
| } | |
| if (root.left != null) { //这里要对root加以控制 否则 root.left会报错 | |
| Mirror(root.left); |
This file contains hidden or 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.Stack; | |
| /** | |
| * @program: work_practice | |
| * @description: 链表的连接 | |
| * @author: LiuYing | |
| * @create: 2019-03-09 16:26 | |
| **/ | |
| public class Solution16 { |
This file contains hidden or 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 ListNode { | |
| int val; | |
| ListNode next = null; | |
| ListNode(int val) { | |
| this.val = val; | |
| } | |
| }*/ | |
| import java.util.Stack; |
This file contains hidden or 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 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; |
This file contains hidden or 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
| /** | |
| * @program: work_practice | |
| * @description: 矩形覆盖问题 | |
| * @author: LiuYing | |
| * @create: 2019-03-08 14:31 | |
| **/ | |
| public class Solution11 { | |
| public int RectCover(int target) { |
This file contains hidden or 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 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; |
NewerOlder