摘要: import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param A string字符串 * @return int整型 */ public int getLonge 阅读全文
posted @ 2023-10-29 20:44 樱圃 阅读(1) 评论(0) 推荐(0) 编辑
摘要: /** * 寻找两个有序数组的中位数 */ public class FindMedianSortedArrays { public static void main(String[] args) { int[] arr1={1,3,4,5}; int[] arr2={1,2,3,6,9}; Sys 阅读全文
posted @ 2023-10-29 20:42 樱圃 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 1 阅读全文
posted @ 2023-10-29 20:39 樱圃 阅读(15) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 验证IP地址 * @param IP string字符串 一个IP地址字符串 * @return string字符串 阅读全文
posted @ 2023-10-29 20:36 樱圃 阅读(6) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int evalRPN(String[] tokens) { Stack st = new Stack(); boolean flag= true; int val =0 ; for(int i =0;i<tokens.length;i++){ if( 阅读全文
posted @ 2023-10-29 20:34 樱圃 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 1 阅读全文
posted @ 2023-10-29 20:30 樱圃 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 描述 输入一个长度为n的整型数组array,数组中的一个或连续多个整数组成一个子数组,子数组最小长度为1。求所有子数组的和的最大值。 数据范围: 1 <= n <= 2\times10^51<=n<=2×105 -100 <= a[i] <= 100−100<=a[i]<=100 要求:时间复杂度为 阅读全文
posted @ 2023-10-29 20:27 樱圃 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 描述 给你一个大小为 n 的字符串数组 strs ,其中包含n个字符串 , 编写一个函数来查找字符串数组中的最长公共前缀,返回这个公共前缀。 数据范围: 0 \le n \le 50000≤n≤5000, 0 \le len(strs_i) \le 50000≤len(strsi​)≤5000 进阶 阅读全文
posted @ 2023-10-29 20:24 樱圃 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 牛客网81 描述 假设你有一个数组prices,长度为n,其中prices[i]是某只股票在第i天的价格,请根据这个价格数组,返回买卖股票能获得的最大收益 1. 你可以多次买卖该只股票,但是再次购买前必须卖出之前的股票 2. 如果不能获取收益,请返回0 3. 假设买入卖出均无手续费 数据范围: 1 阅读全文
posted @ 2023-10-29 20:20 樱圃 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 1 阅读全文
posted @ 2023-10-29 20:18 樱圃 阅读(4) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int mySqrt(int a) { if(a < 2) return a; int start = 2; int end = a/2; int mid = 0; while(start <= end) { mid = start + 阅读全文
posted @ 2023-10-29 20:06 樱圃 阅读(1) 评论(0) 推荐(0) 编辑
摘要: public boolean isValid(String s) { Stack<Character> stack = new Stack<>(); Map<Character,Character> map = new HashMap<>(); char[] chars = s.toCharArra 阅读全文
posted @ 2023-10-29 20:02 樱圃 阅读(13) 评论(0) 推荐(0) 编辑
摘要: public List<List<Integer>> fourSum(int[] nums, int target) { List<List<Integer>> list = new ArrayList<>(); Arrays.sort(nums); int k = 0; // k 的循环 whil 阅读全文
posted @ 2023-10-29 19:25 樱圃 阅读(2) 评论(0) 推荐(0) 编辑
摘要: //思路2:从前向后遍历数组,将非0数字放入一个集合中 public static void moveZeroes02(int[] nums) { if(nums == null || nums.length == 0) { return; } if(nums.length == 1) { retu 阅读全文
posted @ 2023-10-29 17:24 樱圃 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 1 阅读全文
posted @ 2023-10-29 17:17 樱圃 阅读(4) 评论(0) 推荐(0) 编辑
摘要: import csv file = 'D:\\1.csv' with open(file, encoding="UTF8") as f: reader = csv.reader(f) # 创建 读取器 header_row = next(reader) # 获取表的第一行(一般是列名) print( 阅读全文
posted @ 2023-10-29 17:12 樱圃 阅读(22) 评论(0) 推荐(0) 编辑
摘要: public class Solution{ char[] c = s.toCharArray(); int len = c.length; if(len<=2){ System.out.println(c[len]); } int j=-1; for(int i=0;i<len-2;i++){ i 阅读全文
posted @ 2023-10-29 17:08 樱圃 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 1 阅读全文
posted @ 2023-10-29 16:46 樱圃 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 1 阅读全文
posted @ 2023-10-29 16:42 樱圃 阅读(5) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param arr int整型一维数组 the array * @return int整型 */ public 阅读全文
posted @ 2023-10-29 11:00 樱圃 阅读(4) 评论(0) 推荐(0) 编辑