12 2021 档案

摘要:22.括号生成 public List<String> generateParenthesis(int n) { char path[] = new char[n * 2]; List<String> res = new ArrayList<>(); if(n == 0) { return res; 阅读全文
posted @ 2021-12-29 15:42 现在开始努力 阅读(29) 评论(0) 推荐(0)
摘要:14.最长公共前缀 public String longestCommonPrefix(String[] strs) { String first = strs[0]; char f[] = first.toCharArray(); int res = first.length(); for(int 阅读全文
posted @ 2021-12-28 15:45 现在开始努力 阅读(44) 评论(0) 推荐(0)
摘要:7.整数反转 public int reverse(int x) { boolean isFu = x < 0 ? true : false; x = isFu ? x : -x; int res = 0; int M = Integer.MIN_VALUE / 10; int N = Int 阅读全文
posted @ 2021-12-22 14:53 现在开始努力 阅读(30) 评论(0) 推荐(0)
摘要:1.两数之和 public int[] twoSum(int[] nums, int target) { HashMap<Integer,Integer> hm = new HashMap<>(); int res[] = new int[2]; for(int i = 0;i < nums.len 阅读全文
posted @ 2021-12-21 16:32 现在开始努力 阅读(45) 评论(0) 推荐(0)
摘要:1.机器人问题,一共有1-N N个位置,机器人可以在1-N上任意移动,初始位置为start,目标位置为aim,可以移动K次,求有几种移动方式 (1)递归实现 public int ways3(int N,int start,int aim,int K) { return process3(start 阅读全文
posted @ 2021-12-02 18:02 现在开始努力 阅读(68) 评论(0) 推荐(0)