- 博客(13)
- 收藏
- 关注
原创 ProblemSet of Random
470. Implement Rand10() Using Rand7()解法一:/** * The rand7() API is already defined in the parent class SolBase. * public int rand7(); * @return a random integer in the range 1 to 7 */class Solut...
2019-04-28 23:53:56 162
原创 LeetCode--29. Divide Two Integers
30. Substring with Concatenation of All Wordsclass Solution { public List<Integer> findSubstring(String s, String[] words) { int n=words.length; LinkedList<Integ...
2019-04-25 22:54:16 149
原创 《绿皮书》观后感
《绿皮书》作为奥斯卡最佳影片奖名副其实,除了种族歧视的主题外,影片难能可贵地展现了人与人因为经济、政治和生活环境等原因造成的“傲慢与偏见”。影片中,白人对黑人有世俗的鄙视,认为黑人群体都喜欢吃炸鸡,黑人也先入为主的认为白人天生傲慢,看不起他们。绿皮书虽然是为了方便黑人旅行全美使用的,但它的存在是美国深刻的种族歧视的印记!!!黑人钢琴家阿里从小生长在白人歧视的氛围下,在钢琴演奏方面表现优异刻苦,...
2019-04-22 21:22:44 9902
原创 LeetCode--698. Partition to K Equal Sum Subsets
416. Partition Equal Subset Sumclass Solution { public static boolean[] record; public static int sum; public static boolean canPartition(int[] nums) { sum = 0; recor...
2019-04-17 20:58:17 102
原创 LeetCode--416. Partition Equal Subset Sum
416. Partition Equal Subset Sum解法一:深度优先搜索class Solution { public static boolean[] record; public static int sum; public static boolean canPartition(int[] nums) { sum = 0; ...
2019-04-07 12:25:37 123
原创 LeetCode--115. Distinct Subsequences & 132. Palindrome Partitioning II & 174. Dungeon Game
115. Distinct Subsequencesclass Solution { public int numDistinct(String s, String t) { int[][] dp=new int[s.length()+1][t.length()+1]; for(int i=0;i<dp.length;i++) ...
2019-04-06 15:40:09 137
原创 LeetCode--135. Candy
https://leetcode.com/problems/candy/解法一:class Solution { public int candy(int[] ratings) { int[] candies=new int[ratings.length]; Arrays.fill(candies,1); boolea...
2019-04-05 23:15:54 101
原创 LeetCode--87. Scramble String
87. Scramble String暴力递归算法:class Solution { public boolean isScramble(String s1, String s2) { if(s1.length()!=s2.length()) return false; if (s1.equa...
2019-04-04 23:15:38 117
原创 LeetCode--85. Maximal Rectangle
解法一:种子点扩展class Solution { public static int maxArea; public static int N_ROW; public static int N_COL; public int maximalRectangle(char[][] matrix) { N_ROW...
2019-04-04 20:06:33 125
原创 LeetCode 84--Largest Rectangle in Histogram
Largest Rectangle in Histogram单调栈class Solution { public int largestRectangleArea(int[] heights) { Stack<Integer> stack=new Stack<>(); int maxArea=0,n=heights.length;...
2019-04-04 19:49:59 101
原创 LeetCode--93. Restore IP Addresses
93. Restore IP Addresses这个问题基本上就是一个排列组合问题,首先ip地址是四位组成,每一位值都在0-255中取值,除了0以外,所有值都不能以0开头。所以在进行取子字符串时需要特别判断剔除这些情况。class Solution { public static int[] record; public static LinkedList&...
2019-04-03 23:13:42 158
原创 LeetCode--96. Unique Binary Search Trees && 95. Unique Binary Search Trees II
96. Unique Binary Search Trees求第n个卡特兰数class Solution { public int numTrees(int n) { int[] dp=new int[n+1]; dp[0]=1;dp[1]=1; for(int i=2;i<=n;i++) { ...
2019-04-03 22:11:26 103
原创 LeetCode--84. Largest Rectangle in Histogram
84. Largest Rectangle in Histogram暴力解法:class Solution { public int largestRectangleArea(int[] heights) { int n=heights.length; int maxArea=0; for(int i=0;i<n;...
2019-04-03 22:06:58 107
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人