- 博客(13)
- 问答 (1)
- 收藏
- 关注
原创 Redis开发最佳实践
Key的设计易于管理即能通过名称大概知道所涉及业务。通常我们会以service:characteristics来进行命名,如pubg_chat:uid:room_id的形式,这样可以尽可能避免冲突(当然,不同业务使用不同的Redis是更好的)尽量简洁Redis本质上是一个内存数据库,而内存的大小是远小于硬盘的。如果Key过大的话,会导致Redis所能存储的内容变少。所以在日常中推荐Key能...
2019-12-21 11:38:00 1143
原创 【LeetCode】24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y
2017-10-07 13:09:16 223
原创 【LeetCode】3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "
2017-10-06 12:58:49 222
原创 【LeetCode】48. Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:比较简单,自己列出几个矩阵,找规律就成了代码如下:public clas
2017-07-08 20:11:28 165
原创 【LintCode】打劫房屋
打劫房屋 描述 笔记 数据 评测假设你是一个专业的窃贼,准备沿着一条街打劫房屋。每个房子都存放着特定金额的钱。你面临的唯一约束条件是:相邻的房子装着相互联系的防盗系统,且 当相邻的两个房子同一天被打劫时,该系统会自动报警。给定一个非负整数列表,表示每个房子中存放的钱, 算一算,如果今晚去打劫,你最多可以得到多少钱 在不触动报警装置的情况
2017-07-05 18:39:11 199
原创 【LeetCode】16. 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact
2017-07-01 18:21:12 173
原创 【LintCode】买卖股票的最佳时机
假设有一个数组,它的第i个元素是一支给定的股票在第i天的价格。如果你最多只允许完成一次交易(例如,一次买卖股票),设计一个算法来找出最大利润。样例给出一个数组样例 [3,2,3,1,2], 返回 1 思路:简单贪心问题,注意处理边界问题代码如下:public class Solution { /** * @par
2017-06-11 08:44:00 264
原创 【LintCode】合并排序数组 II
合并两个排序的整数数组A和B变成一个新的数组。 注意事项你可以假设A具有足够的空间(A数组的大小大于或等于m+n)去添加B中的元素样例给出 A = [1, 2, 3, empty, empty], B = [4, 5]合并之后 A 将变成 [1,2,3,4,5]思路:也是道归并排序题。不过排序可以不增加辅助数组,直接从A的末端
2017-06-10 22:16:43 610
原创 【LintCode】最大子数组
最大子数组 描述 笔记 数据 评测给定一个整数数组,找到一个具有最大和的子数组,返回其最大和。 注意事项子数组最少包含一个数样例给出数组[−2,2,−3,4,−1,2,1,−5,3],符合要求的子数组为[4,−1,2,1],其最大和为6思路:思路很简单,可以
2017-06-10 17:47:59 263
原创 【LintCode】删除排序数组中的重复数字
删除排序数组中的重复数字 描述:给定一个排序数组,在原数组中删除重复出现的数字,使得每个元素只出现一次,并且返回新的数组的长度。不要使用额外的数组空间,必须在原地没有额外空间的条件下完成。样例给出数组A =[1,1,2],你的函数应该返回长度2,此时A=[1,2]。思路:因为不让使用额外数组空间,所以只能从原来
2017-06-09 21:11:46 1754
原创 【LeetCode】9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of convertin
2017-06-09 14:39:55 192
原创 【LeetCode】7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your function s
2017-06-09 11:17:27 181
原创 【LeetCode】4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 =
2017-06-08 14:45:54 235
空空如也
SSM 如何对多个service进行回滚
2018-11-05
TA创建的收藏夹 TA关注的收藏夹
TA关注的人