自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

原创 70. 爬楼梯

//超时 class Solution {     public int climbStairs(int n) {          if(n==1) return 1;         else if(n==2) return 2;         return climbStairs(n-1)+climbStairs(n-2);     } } //借助数组,对中间结果进行存储 clas...

2018-12-20 11:28:33 99

原创 680. 验证回文字符串 Ⅱ

//超时 class Solution {     public boolean validPalindrome(String s) {         int len=s.length();         if(Palindrome(s)) return true;         for (int i = 0; i <len ; i++) {             String t...

2018-12-20 11:14:08 138

原创 443. 压缩字符串

class Solution {    public int compress(char[] chars) {         int len = chars.length;         int count = 0;         Stack<Character> s = new Stack<>();         String temp = "";        ...

2018-12-20 10:25:09 168

原创 414. 第三大的数

觉得第三个实例是错的呀,按照通过的代码第三大的数并不是唯一出现的 按照唯一出现写的代码不通过,不唯一的就通过了 解释: 注意,要求返回第三大的数,是指第三大且唯一出现的数。 存在两个值为2的数,它们都排第二。     class Solution {     public int thirdMax(int[] nums) {            Arrays.sort(nums);    ...

2018-12-20 09:36:42 120

原创 Leetcode 633. 平方数之和

class Solution {     public boolean judgeSquareSum(int c) {         for (int i = 0; i <=(int)Math.sqrt(c); i++) {             { int sub=c-i*i;                if(Math.abs(Math.sqrt(sub)-(int)Math.sq...

2018-12-19 22:19:38 146

原创 Leetcode 551. 学生出勤记录 I

class Solution {     public boolean checkRecord(String s) {         int len=s.length();         int countA=0;         int countL=0;         for (int i = 0; i < len; i++) {             if(s.charAt(i...

2018-12-19 21:54:18 281

原创 941 有效的山脉数组

import java.util.Arrays; public class Leecode941{ public static void main(String[] args) { int a[]={14,82,89,84,79,70,70,68,67,66,63,60,58,54,44,43,32,28,26,25,22,15,13,12,10,8,7,5,4,3}; ...

2018-12-19 21:29:18 172

原创 884. 两句话中的不常见单词

/*注意这里就可以了:   map.entrySet()    Map.Entry<E,V>  for (Map.Entry<String,Integer> entry: Mb.entrySet()) { */   class Solution {     public String[] uncommonFromSentences(String A, String...

2018-12-19 20:35:40 302

原创 867. 转置矩阵

class Solution {     public int[][] transpose(int[][] A) {         int down=A.length;         int up=A[0].length;         int a[][]=new int[up][down];         for(int i=0;i<down;i++)             fo...

2018-12-19 20:05:37 210

原创 leecode 415. 字符串相加

class Solution {     public String addStrings(String num1, String num2) {         int len1=num1.length();         int len2=num2.length();         if(len1>len2) {             for (int i = 0; i < ...

2018-12-19 15:40:39 115 1

原创 917. 仅仅反转字母

class Solution {     public String reverseOnlyLetters(String S) {         Stack<Character> s=new Stack<Character>();         int len=S.length();         for (int i = 0; i <len ; i++) { ...

2018-12-19 13:02:44 262

原创 21. 合并两个有序链表

/**  * Definition for singly-linked list.  * public class ListNode {  *     int val;  *     ListNode next;  *     ListNode(int x) { val = x; }  * }  */ class Solution {     public ListNode mergeTwoLis...

2018-12-19 12:43:49 64

原创 Leecode53 最大和子序列

///动态规划 dp[i]=Math.max(dp[i-1]+nums[i],nums[i]);挺简单的,下面这个,就是直接输出最大值,但是没有记录下具体数字序列是多少 public class Leecode51 { public static void main(String[] args) { int a[]={-2,11,-4,13,-5,-2}; ...

2018-12-19 12:00:16 115

原创 leecode7:整数反转

class Solution {     public int reverse(int x) {         if(x<-2147483648||x>2147483647) return 0;//tips1:范围很重要         int flag=1;         if(x<0)         {flag=-1;x=-1*x;}         String s...

2018-12-19 10:55:27 146

原创 leecode23 合并K个排序链表

  /**  * Definition for singly-linked list.  * public class ListNode {  *     int val;  *     ListNode next;  *     ListNode(int x) { val = x; }  * }  */ class Solution {     public ListNode merge2Li...

2018-12-18 10:44:23 128

原创 leecode14. 最长公共前缀

好久没练leecode,怕自己费了,本来就是渣渣一枚。 思路:step1:找数组里面的最短字符串            step2:遍历数组里面的所有字符串,看是否是相同的,相同就放入stringbuilder,否则可以返回了   最后通过的代码: class Solution {     public String longestCommonPrefix(String[] strs) ...

2018-12-14 10:00:00 122

原创 lsc问题

如果一个字符串S是由两个字符串T连接而成,即S = T + T, 我们就称S叫做平方串,例如"","aabaab","xxxx"都是平方串. 牛牛现在有一个字符串s,请你帮助牛牛从s中移除尽量少的字符,让剩下的字符串是一个平方串。换句话说,就是找出s的最长子序列并且这个子序列构成一个平方串。 输入描述: 输入一个字符串s,字符串长度length(1 ≤ length ≤ 50),字符串只包括...

2018-09-01 23:22:21 706

原创 编写程序过程

  给定一个数组序列, 需要求选出一个区间, 使得该区间是所有区间中经过如下计算的值最大的一个: 区间中的最小数 * 区间所有数的和最后程序输出经过计算后的最大值即可,不需要输出具体的区间。如给定序列  [6 2 1]则根据上述公式, 可得到所有可以选定各个区间的计算值:   [6] = 6 * 6 = 36; [2] = 2 * 2 = 4; [1] = 1 * 1 = 1; [6...

2018-08-31 10:30:46 176

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除