上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: 还是暴力写法 转成数加一再压回 下面有错误 对于超过int类型的整数出错 还没有改好 class Solution { public int[] plusOne(int[] digits) { int sum=0; int count=0; int flag=0; int l=digits.leng 阅读全文
posted @ 2022-05-11 12:42 Ssshiny 阅读(24) 评论(1) 推荐(0)
摘要: 没带笔记本 不知道怎么截取单个字符 其实单个字符比较更简单 自己也想出来了 class Solution { public int lengthOfLastWord(String s) { int num=0; int tail=s.length(); int head;// System.out. 阅读全文
posted @ 2021-11-01 22:40 Ssshiny 阅读(27) 评论(0) 推荐(0)
摘要: 用到了动态规划,看了题解写了以下思路 class Solution { public int maxSubArray(int[] nums) { // double res=-1E4; // System.out.println(res); //科学计数法 只能是double float型 int 阅读全文
posted @ 2021-10-31 16:37 Ssshiny 阅读(34) 评论(1) 推荐(0)
摘要: 很容易实现 最开始在不存在的元素找插入位置时饶了小小一点弯路 最开始想要每次mid改变都记录下来 改出来一点错误 class Solution { public int searchInsert(int[] nums, int target) { int loc=0; int low=0,high= 阅读全文
posted @ 2021-10-31 13:17 Ssshiny 阅读(30) 评论(1) 推荐(0)
摘要: 看了字符串截取子字符的库函数 第一次没有加等于号 舍去了末尾的比较这种情况 快速算法是kmp算法 class Solution { public int strStr(String haystack, String needle) { int loc=-1; for(int i=0;i<haysta 阅读全文
posted @ 2021-10-31 12:38 Ssshiny 阅读(34) 评论(0) 推荐(0)
摘要: class Solution { public int removeElement(int[] nums, int val) { int length=nums.length; //最初设置返回长度为数组长度 即不删减的情况下 for(int i=0;i<length;i++) { if(nums[ 阅读全文
posted @ 2021-10-29 17:38 Ssshiny 阅读(29) 评论(2) 推荐(0)
摘要: 跟我妈打电话的时候 随便写了写 一次就过啦 今日份开心 但是我的内存占用很大很大 基本上就是暴力求解 好好学一下栈 和 各种排序查找算法 class Solution { public int[] nextGreaterElement(int[] nums1, int[] nums2) { int 阅读全文
posted @ 2021-10-26 22:51 Ssshiny 阅读(29) 评论(2) 推荐(0)
摘要: 要自己有判断边界和特殊案例的能力 改正后的代码如下 package leetcode; class Solution { public int removeDuplicates(int[] nums) { int num=nums.length; int index=0; //标志往前移动的第一个数 阅读全文
posted @ 2021-10-25 23:40 Ssshiny 阅读(31) 评论(0) 推荐(0)
摘要: 最初有一个bug 就是当等于第一行的数字时 出错 自己默认以为第二行必定比第一行数字大 其实并不是的 形如 {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20},{21,22,23,24,25}};也满足横向递增 竖向递增 因此虽然能 阅读全文
posted @ 2021-10-25 19:56 Ssshiny 阅读(48) 评论(0) 推荐(0)
摘要: package leetcode; class ListNode { int val; ListNode next; ListNode() {} ListNode(int val) { this.val = val; } ListNode(int val, ListNode next) { this 阅读全文
posted @ 2021-10-25 11:29 Ssshiny 阅读(37) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 下一页