12 2021 档案

摘要:中间temp temp = a; a = b; b = temp; 相加减 a = a + b; b = a - b; a = a - b; 或 a = a - b; b = a + b; a = b - a; 位操作 a = a ^ b; b = a ^ b; a = a ^ b; 阅读全文
posted @ 2021-12-20 15:20 啤酒加点醋 阅读(104) 评论(0) 推荐(0) 编辑
摘要:给你一个数组,将数组中的元素向右轮转 k 个位置,其中 k 是非负数。 示例 1: 输入: nums = [1,2,3,4,5,6,7], k = 3 输出: [5,6,7,1,2,3,4] 解释: 向右轮转 1 步: [7,1,2,3,4,5,6] 向右轮转 2 步: [6,7,1,2,3,4,5 阅读全文
posted @ 2021-12-16 18:08 啤酒加点醋 阅读(31) 评论(0) 推荐(0) 编辑
摘要:给定一个数组 prices ,其中 prices[i] 是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 示例 1: 输入: prices = [7,1, 阅读全文
posted @ 2021-12-16 15:49 啤酒加点醋 阅读(20) 评论(0) 推荐(0) 编辑
摘要:Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume t 阅读全文
posted @ 2021-12-16 13:12 啤酒加点醋 阅读(16) 评论(0) 推荐(0) 编辑
摘要:A parentheses string is valid if and only if: It is the empty string, It can be written as AB (A concatenated with B), where A and B are valid strings 阅读全文
posted @ 2021-12-15 15:03 啤酒加点醋 阅读(23) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linea 阅读全文
posted @ 2021-12-14 22:04 啤酒加点醋 阅读(25) 评论(0) 推荐(0) 编辑
摘要:给定一个整数数组,判断是否存在重复元素。 如果存在一值在数组中出现至少两次,函数返回 true 。如果数组中每个元素都不相同,则返回 false 。 题解一:双循环 class Solution { public boolean containsDuplicate(int[] nums) { for 阅读全文
posted @ 2021-12-12 15:31 啤酒加点醋 阅读(26) 评论(0) 推荐(0) 编辑
摘要:/* 带有哨兵的链表。哨兵所在的位置是真正列表开始前的一位。记住这一点,即可轻松理解哨兵含义,并编写addFirst和addLast方法。*/ // first是否为空影响某些情况的判断,既然这样,找一个哨兵,指向first。就可解决这一问题。这个思路很好。 public class SLList_ 阅读全文
posted @ 2021-12-09 19:05 啤酒加点醋 阅读(76) 评论(0) 推荐(0) 编辑
摘要:简单的List功能实现,v1 public class SLList_1{ public static class IntNode{ public int item; public IntNode next; public IntNode(int i, IntNode n){ item = i; n 阅读全文
posted @ 2021-12-08 12:11 啤酒加点醋 阅读(27) 评论(0) 推荐(0) 编辑
摘要:1. .*转 .eps bmeps -c img.png img.eps 阅读全文
posted @ 2021-12-08 12:03 啤酒加点醋 阅读(9) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示