自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

CherishBliss的博客

cherish bliss...

  • 博客(40)
  • 收藏
  • 关注

原创 53. Maximum Subarray(DP)

问题Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanation:...

2018-04-26 16:25:39 304

原创 121. Best Time to Buy and Sell Stock

 问题Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock)...

2018-04-26 15:45:14 151

原创 70. Climbing Stairs

问题You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive i...

2018-04-26 15:21:21 156

原创 278. First Bad Version

题目You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on t...

2018-04-26 14:12:57 257

原创 88. Merge Sorted Array

题目Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that nu...

2018-04-26 13:56:29 110

原创 108. Convert Sorted Array to Binary Search Tree

题目Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...

2018-04-26 13:11:57 204

原创 102. Binary Tree Level Order Traversal (二叉树层次遍历)

题目Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / ...

2018-04-26 01:58:15 255

原创 101. Symmetric Tree

题目Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But t...

2018-04-26 01:35:55 126

原创 98. Validate Binary Search Tree (inorder traversal)

题目Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.The righ...

2018-04-26 01:31:10 106

原创 104. Maximum Depth of Binary Tree

题目Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no children....

2018-04-25 20:44:39 102

原创 141. Linked List Cycle

题目Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?分析1 判断链表是否有环 way 1 快慢指针                            way 2 每遍历一个结点都将这个结点指向本身,如果再次遍历到指向其本身的结点...

2018-04-25 20:22:43 88

原创 234. Palindrome Linked List

题目Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?分析1 题目要求 time O(n) space O(1), 意味着要在原链表操作2 对于链表的回文串的判断,只能通过翻转 然后两个链表再从头到尾的进行比较    翻转...

2018-04-25 15:08:05 102

原创 21. Merge Two Sorted Lists

题目Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1-&gt...

2018-04-25 13:50:34 92

原创 19. Remove Nth Node From End of List

题目Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the ...

2018-04-25 12:39:38 111

原创 LeetCode 237 Delete Node in a Linked List

题目Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node wit...

2018-04-25 12:17:18 112

原创 LeetCode 203 删除链表中的元素

题目删除链表中等于给定值 val 的所有元素。示例给定: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6返回: 1 --> 2 --> 3 --> 4 --> 5分析1 第一道链表结构的题2 两种思路 1 递归的方式来做                2 创造一个结点,while循环的方式来做...

2018-04-25 12:09:00 134

原创 LeetCode - 138 只出现一次的数字

题目给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。说明:你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗?分析1 本来想的是用Java里的排序,排完顺序之后,再分第一个位置 和中间位置处理, 最后返回最后一个位置  这样的做法显然不是很好,不说用到了Java里的arrays.sort 在找出唯一的那个不是出现两次的元素用到的方法...

2018-04-25 11:55:32 559

原创 LeetCode -122- 两次买卖问题

贪心算法初始值 到 结束值的距离就在那儿无论一步走,多步走的结果都是一样的

2018-04-25 11:26:38 271

原创 LeetCode 14 Longest Common Prefix

题目Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".分析1 注意是最长公共前缀,一开始没注意到这个条件浪费了一些时间2 Java里的两个字符串的匹配函数 index...

2018-04-25 11:26:05 148

原创 LeetCode 28 Implement strStr()

问题Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.分析1 可以理解为字符串匹配题2 如果needle为空怎么办,直接返回03 time o(m*n) 4 for循环中不加条件语句,永为真 ,函数可以不...

2018-04-24 18:20:48 140

原创 LeetCode 8 String to Integer (atoi)

问题Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from thi...

2018-04-24 17:35:36 115

原创 LeetCode 125 验证回文串

问题Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palindrome.Example...

2018-04-24 16:10:54 3935

原创 LeetCode 387 字符串中唯一的字符

题目Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note: You may assu...

2018-04-24 12:55:29 130

原创 LeetCode 7 Reverse Int

题目翻转整数分析1 Java里整数的范围是多少 - 2 32 ~ 2 32 - 1 (有0存在) Integer.MAX_VALUE2 越界问题 通常用long型来避免越界的问题代码class Solution { public int reverse(int x) { long res = 0; while (x != 0){ re...

2018-04-24 12:19:45 90

原创 LeetCode 48 Rotate Image

题目You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the input 2D matrix direc...

2018-04-24 11:46:22 118

原创 LeetCode 1 two Sum

问题Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ...

2018-04-24 11:27:55 96

原创 LeetCode 288 移动0

题目给定一个数组 nums, 编写一个函数将所有 0 移动到它的末尾,同时保持非零元素的相对顺序。例如, 定义 nums = [0, 1, 0, 3, 12],调用函数之后, nums 应为 [1, 3, 12, 0, 0]。注意事项:必须在原数组上操作,不要为一个新数组分配额外空间。尽量减少操作总数分析1 只需要维护一个id, 这个id记录当前已经确定好的元素的位置,id++    这里有个处理...

2018-04-24 10:47:58 200

原创 LeetCode 66 Plus one

题目给定一个非负整数组成的非空数组,在该数的基础上加一,返回一个新的数组。最高位数字存放在数组的首位, 数组中每个元素只存储一个数字。你可以假设除了整数 0 之外,这个整数不会以零开头。分析1 从末尾开始遍历 如果是9 变为0 否则加1返回2 如果遍历完都没有返回 说明是类似999,这时构造一个新数组 array.length + 1代码class Solution { public in...

2018-04-24 01:45:24 108

原创 LeetCode 217 重复的数

tips:1 两次循环 2 arrays.sort3 hashSet set    类比Arraylist 数组          set.contains(i)          set.add          list.get(idx)题目给定两个数组,写一个方法来计算它们的交集。例如:给定 nums1 = [1, 2, 2, 1], nums2 = [2, 2], 返回 [2, 2].注意...

2018-04-24 01:23:57 99

原创 LeetCode - 344 翻转字符串

题目请编写一个函数,其功能是将输入的字符串反转过来。例 hello -- olleh分析1 这里用到Java里的string常用的处理方式 tochararray将string处理为char类型的数组,一开始想直接在原string上调用.charat来处理,结果这样是不可行的。所以第一步是将string转换成char数组2 翻转这个char数组 常用的while循环3 char数组转换成strin...

2018-04-19 21:44:08 1776

原创 LeetCode - 189 旋转数组

题目将包含 n 个元素的数组向右旋转 k 步。例如,如果  n = 7 ,  k = 3,给定数组  [1,2,3,4,5,6,7]  ,向右旋转后的结果为 [5,6,7,1,2,3,4]。注意:尽可能找到更多的解决方案,这里最少有三种不同的方法解决这个问题。思路1 题目比较好理解,但是自己在第一次写的时候却不是那么容易,关键是理清关系2 对于way 1 首先是k, 简单通俗的将 k为3时, 数组...

2018-04-19 21:26:00 449

原创 LeetCode - 206 翻转链表

题目反转一个单链表。思路1 两种方案,递归和非递归2 这里用到了链表的数据结构,注意数据结构的定义,包括构造函数等3 递归方案 递归函数传递两个参数,开始是头结点和null                   1 先判断head是否为空节点,空直接返回null                    2 next 保存 head 的下个结点, head指向为空                    ...

2018-04-19 20:42:06 375

原创 LeetCode - 26 删除排序数组中的重复项

题目给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。思路1 不需要额外数组,直接修改原数组,所以不能new int[array.length]记录独立的数值2 需要记录一个索引index来保存确定好了的不重复的位置3 num[i++] 这种表示都是先试用后加,...

2018-04-18 20:56:06 394

原创 一些快捷键

IDEA        ctrl + n 查找类        ctrl + shift + n 查找文件        sout  等效于System.out.println        fori  遍历        psvm main()函数        ...

2018-04-13 10:20:51 148

原创 netty中的TCP的黏包/拆包

TCP黏包/拆包原理    TCP是一个流的协议。一个完整的包可能被TCP拆分为多个包进行发送;也有可能把多个小的包封装成一个大的数据包一起发送     例如            客户端发送两个包给服务器,可能产生的情况:                1 a b单独发送                2 a b部分 b部分                ...                服...

2018-04-12 17:37:13 305

原创 棋牌游戏Server结构

c s具体通信流程      服务器间的交互                                  与数据库交互的服务器                           玩法服务器                                      现有的gameserver/battleserver的负载有多少?       几万,battleserver负载均衡创建一个房...

2018-04-12 16:04:56 2697

转载 CAS单点登录

单点登录之前在韵达时用到过,同一个账号可以登录多个相关系统;现在棋牌多地区的登录也是用到了。CAS是不错的sso实现https://blog.csdn.net/csdnxingyuntian/article/details/54970102...

2018-04-02 18:29:58 206

转载 目前项目的客户端服务器架构

CClient 客户端SServer 游戏服务器玩法服务器 :BattleServer平台服务器Auth Server : 认证服务器Club Server : 俱乐部服务器Compaign Server : 比赛服务器Game Server : 游戏服务器,通用基础功能,功能范畴没有严格界定Interface Server : 对外接口服务器Manager Server : 管理服务器,管理服务...

2018-04-02 11:24:40 482

原创 redis如何模糊查询

复试时老师问了两个问题,感觉回答的不是很好1 key value数据库应用于哪些场景,与关系型数据库的区别2 redis数据库如何进行模糊查询

2018-04-01 20:10:16 6801

原创 初衷

想了很久,还是决定开始记录一下平时的点滴,可以是一个闪光,也可以是一个吐槽,也可以是一个积累,总之,想保留下来的东西还是尽量记录下来,因为记忆不太好了。关于记忆不太好,不知道从什么时候开始的,彷佛从小学时就开始了?反正在学生生涯有个几次这样的感觉,让我感觉的确记忆力不是很好。最近尤甚?还是一直如此?好吧,这样的计较好像没什么意义。所以,第一篇博文就是这样了,希望以后能多写点东西,毕竟记忆不好啊。...

2018-04-01 20:07:03 125

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除