- 博客(27)
- 收藏
- 关注
原创 Maximum Product Subarray(Medium)
Maximum Product Subarray by Leetcodejava编写class Solution {public int maxProduct(int[] nums) {if (nums == null || nums.length <= 0) return 0;int currMaxProd = nums[0];int currMinProd = nums[0]...
2019-04-18 00:04:39 155
原创 Triangle(Medium)
Triangle by LeetCodejava编写public class Triangle {public static int minimumTotal(List<List> triangle) {dfs(triangle, 0, 0, 0);return sum1;}public static void dfs(List<List> triangle,...
2019-04-16 23:55:30 254
原创 Construct Binary Tree from Preorder and Inorder Traversal(Medium)
Construct Binary Tree from Preorder and Inorder Traversal by LeetCodejava编写/**Definition for a binary tree node.public class TreeNode {int val;TreeNode left;TreeNode right;TreeNode(...
2019-04-15 23:32:08 144
原创 Search in Rotated Sorted Array II(Medium)
Search in Rotated Sorted Array II by LeetCodejava编写public boolean search(int[] nums, int target) {int left = 0, right = nums.length - 1;while(left <= right) {int mid = (left + right) / 2;if(t...
2019-04-14 23:42:39 161
原创 图片加密
public class PictureEncryption {public void getImagePixel(String image) throws Exception { int[] rgb = new int[3]; File file = new File(image); BufferedImage bi = null; try { bi = ImageIO.read(...
2019-04-13 23:20:59 308
原创 Remove Duplicates from Sorted Array II(Medium)
Remove Duplicates from Sorted Array II by LeetCodejava编写class Solution {public int removeDuplicates(int[] nums) {if (nums.length <= 2)return nums.length;int count = 2, last = nums[0];for (in...
2019-04-13 23:16:13 97
转载 字符串转成二进制码&&二进制码转成字符串
Java将字符串转成二进制码public void toBinary(){String str = “王雪”;char[] strChar=str.toCharArray();String result="";for(int i=0;i<strChar.length;i++){result +=Integer.toBinaryString(strChar[i])+ " ";}...
2019-04-11 22:48:08 1797
原创 Word serach(Medium)
Word search by LeetCodejava编写public class word_search { static boolean xx;public static void main(String[] args) {char[][] a = {{‘A’,‘B’,‘C’,‘E’},{‘S’,‘F’,‘C’,‘S’},{‘A’,‘D’,‘E’,‘E’}};System.ou...
2019-04-11 21:12:30 131
原创 Subsets(Medium)
Subsets by LeetCodejava编写public class Subsets {public static void main(String[] args) {int[] a = {1,2,3};subsets(a);}public static List<List> subsets(int[] nums) {List<List> result...
2019-04-10 22:46:37 119
原创 Set Matrix Zeroes(Medium)
Set Matrix Zeroes by LeeetCodejava编写public class Set_Matrix_Zeroes {public static void main(String[] args) {int[][]a= { {0,1,2,0},{3,4,5,2},{1,3,1,5}};setZeroes(a);}public static void setZero...
2019-04-10 20:10:35 104
原创 Minimum Path Sum(Medium)
Minimum Path Sum by LeetCodejava编写public class Minimum_Path_Sum {static int sum=0;static boolean pan=false;public static void main(String[] args) {int[][] a= {{1,3,1,9,4},{1,5,1,2,1},{4,1,1,1...
2019-04-09 21:57:43 111
原创 Unique Paths(Medium)
Unique Paths by LeetCodejava编写public class Unique_Paths {static int count;static int x=0;static int y=0;public static void main(String[] args) {System.out.println(uniquePaths(7, 3));}public s...
2019-04-09 20:33:42 180
原创 Spiral Matrix(Medium)
Spiral Matrix II by Leetcodejava编写class Solution {static int x=0;static int y=0;static int i=0;public int[][] generateMatrix(int n) {int [][]a = new int[n][n];if(n==1){a[0][0]=1;return a;}...
2019-04-08 22:22:03 179 1
原创 Merge Intervals(Medium)
Merge Intervals by LeetCodejava编写public List merge(List intervals) {if (intervals.size() <= 1)return intervals;// Sort by ascending starting point using an anonymous Comparatorintervals.sort(...
2019-04-08 21:11:28 168
原创 jump game(Medium)
jump game by Leetcodejava编写public boolean canJump(int[] nums) {int far = 0;for(int i = 0; i < nums.length; i++){if(i <= far){far = Math.max(far, i+nums[i]);} else return false;}return t...
2019-04-06 16:58:59 93
原创 Spiral Matrix(Medium)
Spiral Matrix by leetcodejava编写class Solution {static int x=0;static int y=0;public static List spiralOrder(int[][] matrix) {List list = new ArrayList<>();if(matrix.length == 0){return n...
2019-04-05 00:31:40 91
原创 Rotate_image(Medium)
Rotae Image by leetcodejava编写class Solution {public void rotate(int[][] matrix) {List list = new ArrayList<>();for(int i =0;i<matrix.length;i++)for(int j=0;j<matrix.length;j++) {lis...
2019-04-04 21:24:57 174
原创 Combination Sum(Medium)
Combination Sum by leetcodejava编程public class Combination_Sum {public static void main(String[] args) { List<List<Integer>> list; int[] a= {2,3,6,7} ; int target = 7; list=combinat...
2019-04-03 22:24:49 133
原创 Find First and Last Position of Element in Sorted Array(Medium)
Find First and Last Position of Element in Sorted Array bu leetcodejava编写public class Find_First_and_Last_Position_of_Element {public static void main(String[] args) { int[] a = {}; for(int x: se...
2019-04-03 18:50:58 122
原创 Longest Substring Without Repeating(Medium)
Longest Substring Without Repeating Characters by Leetcodejava编写public static int lengthOfLongestSubstring(String s) {int max=0;if(s!="") {String[] s1=s.split("");String s2="";int x=0;for(int ...
2019-04-03 16:42:20 88
原创 Serarch in Rotated Sorted(Medium)
Serarch in Rotated Sorted by leetcodejava编写public int search(int[] nums, int target) {if(nums == null || nums.length == 0) return -1;int left = 0;int right = nums.length - 1;while(left < righ...
2019-04-02 23:01:49 78
原创 Next permutation(Medium)
Next permutation by Leetcodejava编写public void nextPermutation(int[] nums) {int i = nums.length - 2;while (i >= 0 && nums[i + 1] <= nums[i]) {i–;}if (i >= 0) {int j = nums.leng...
2019-04-02 20:26:07 84
原创 3sum closest(Medium)
3Sum closest by Leetcodejava编写import java.util.Arrays;public class Sum_3_Closest {public static void main(String[] args) { int[] a = {-1,2,1,-4};System.out.println(threeSumClosest(a, 1)); }pu...
2019-04-02 16:51:18 57
原创 3Sum(Medium)
3Sum by Leetcodejava编写public class Sum_3 {public static void main(String[] args) { List<List<Integer>> list; int[] a = {-1, 0, 1, 2, -1, -4}; list = threeSum(a); for(List<Integer...
2019-04-01 23:21:22 73
原创 Container With Most Water(Medium)
Container With Most Water by Leetcodejava编写public class Container_With_Most_Water {public static void main(String[] args) { int[] a = {1,8,6,2,5,4,8,3,7}; System.out.print(maxArea(a));}public ...
2019-04-01 19:47:00 79
原创 add two numbers(Medium)
add two numbers by LeetCodejava编写public class Add_Two_Numbers {public static void main(String[] args) { ListNode node1=new ListNode(2); ListNode node2=new ListNode(5); node1.next=new ListNode(4)...
2019-03-31 22:07:23 74
原创 twosum(Easy)
two sum by LeetCodejava编写public class twoSum {public static void main(String[] args) {int[] nums= {2,7,11,15};int target = 9;twoSum(nums,target);for(int a:twoSum(nums,target)) {System.out.prin...
2019-03-31 20:03:47 82
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人