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.LinkedList; | |
import java.util.List; | |
public class LK114 { | |
public static class TreeNode { | |
int val; | |
TreeNode left; | |
TreeNode right; |
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 LK113 { | |
public class TreeNode { | |
int val; | |
TreeNode left; | |
TreeNode right; | |
TreeNode() { | |
} | |
TreeNode(int 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
class Solution { | |
public boolean hasPathSum(TreeNode node, int targetSum) { | |
if (node == null) { | |
return false; | |
} | |
targetSum = targetSum - node.val; | |
if (node.left == null && node.right == null) { | |
return targetSum == 0; | |
} | |
boolean leftSum = node.left != null && hasPathSum(node.left, targetSum); |
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
class Solution { | |
public int minDepth(TreeNode node) { | |
if (node == null) { | |
return 0; | |
} | |
if (node.left == null && node.right == null) { | |
return 1; | |
} | |
int minLeftNum = node.left == null ? Integer.MAX_VALUE : minDepth(node.left); | |
int minRightNum = node.right == null ? Integer.MAX_VALUE : minDepth(node.right); |
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
/** | |
* Definition for a binary tree node. | |
* public class TreeNode { | |
* int val; | |
* TreeNode left; | |
* TreeNode right; | |
* TreeNode() {} | |
* TreeNode(int val) { this.val = val; } | |
* TreeNode(int val, TreeNode left, TreeNode right) { | |
* this.val = 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
public class LK101 { | |
public class TreeNode { | |
int val; | |
TreeNode left; | |
TreeNode right; | |
TreeNode() { | |
} | |
TreeNode(int 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
public class LK866 { | |
public int primePalindrome(int N) { | |
while(true) { | |
if (isHw(String.valueOf(N)) && isSh(N)) { | |
return N; | |
} | |
N++; | |
} | |
} |
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
题目: | |
给定一个字符串,编写一个函数判定其是否为某个回文串的排列之一。 | |
回文串是指正反两个方向都一样的单词或短语。排列是指字母的重新排列。 | |
回文串不一定是字典当中的单词。 | |
示例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 ListNode removeElements(ListNode head, int val) { | |
ListNode t = head; | |
ListNode trail = null; | |
while(t != null) { | |
ListNode next = t.next; | |
if (t.val == val) { | |
//remove val | |
t.next = null; | |
if (trail == null) { | |
head = next; |
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
//IPv4地址可被写作任何表示一个32位整数值的形式,但为了方便人类阅读和分析,它通常被写作点分十进制的形式,即四个字节被分开用十进制写出,中间用点分隔. | |
所以ipv4本质是一个无符号的int类型,可以比较大小。 | |
public class Main{ | |
public static void main(String[] args) { | |
String ipString = "10.8.105.6"; | |
System.out.println(ip2Int(ipString)); | |
System.out.println(intoToIp(168323334));; | |
} | |
//ip字符串转int |
NewerOlder