- 博客(29)
- 收藏
- 关注
原创 百信银行社招面试
上周六去百信银行参加了社招面试,受到了一些打击,面试我的应该是架构师级别的大牛,对分布式架构/微服务很感兴趣,而我对这方面了解不多,所以面试效果不怎么理想。另外还问了一些spring框架、java多线程的一些问题,但是自己感觉每个问题都没答到点子上,可以很明显的看出面试官早就对我失去了兴趣。还是自己技不如人啊。...
2018-03-26 21:16:06 5419 2
原创 重新找回了csdn的密码
离现在最近的一篇博客居然是2014年七月份的,离现在已经有三年了。这三年发生了很多事,我的生活有了很大的变化:找到了工作、结了婚。。。,我以前都没有想到自己的生活会变成现在这个样子。有的东西变了,有的东西依然没变。leetcode也没有刷完,做过的题目已经忘了。
2017-04-13 21:38:56 1365
原创 Leetcode: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
2014-07-12 08:42:21 812
原创 Leetcode:Sort List 对单链表归并排序
Sort a linked list in O(n log n) time using constant space complexity.看到O(n log n)的排序算法,适合单链表的首先想到的就是归并排序/** * Definition for singly-linked list. * struct ListNode { * int val; * Lis
2014-07-01 21:53:42 916
原创 归并排序
void merge_array(int list1,int list1_size,int list2,int list2_size){ int i,j,k; i=j=k=0; //声明临时数组用暂存归并结果 int list[list1_size + list2_size]; while(i < list1_size && j < l
2014-07-01 21:26:14 646
原创 Leetcode: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.代码如下:* Definition for singly-linked list. * struct L
2014-07-01 20:49:07 782
原创 求树的子结构
好长时间不更新博客了,今天看到一道以前做过的题(题目来自《剑指offer》),再练一下:我的思路如下:判断B是不是A的子结构,就是要判断B是不是和A中的一部分结构是不是完全相同,需要一个节点一个节点的判断,只要有一个节点不同,就返回false。这部分代码如下:bool isEqual(TreeNode *head1,TreeNode *head2){ if(head
2014-06-15 17:10:43 977
原创 Leetcode:Reverse Linked List II 单链表区间范围内逆置
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the fol
2014-05-20 23:23:20 882
原创 Leetcode:Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur
2014-05-04 22:58:21 775
原创 Leetcode:Subsets 求数组的所有子集
Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For exa
2014-05-02 20:25:57 10232
原创 Leetcode: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?刚开始没有思路,但是自己举了几个简单的栗子才看出规律:需要一圈儿一圈儿的变换位置。有两层for循环:外
2014-05-01 16:08:15 849
原创 Leetcode:Container with most water 最大蓄水量
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin
2014-04-28 20:55:03 1223
原创 Leetcode:Reorder List 单链表重排序
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to
2014-04-28 18:37:03 999
原创 Leetcode:Add Binary 二进制相加
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路同十进制的大数相加。代码如下:class Solution {public: string addBinary(string a, str
2014-04-28 16:02:06 1189
原创 Leetcode:Minimum Path Sum 最小路径和
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at
2014-04-28 10:29:09 755
原创 Topcoder:Zigzag 最长的大小交替子数组
在topcoder上闲逛,看到了这个题,就索性做了一下。题意:zigzag序列是指数组中连续元素之间的差正负交替,第一个差(若存在)可正可负,只有一个元素时也可被看成是一个zigzag序列。例如:1,7,4,9,2,5是一个zigzag序列,因为连续元素之间的差值为6,-3,5,-7,3正负交替。1,4,7,2,5和1,7,4,5,5不是zigzag序列,因为前者的前两个差值为3,3;后者
2014-04-27 09:58:02 2359
原创 Life is hard!
有的人越活越乐观,有的人越活越悲观,有的人越活越达观。有的人的路越走越窄,有的人的路越走越宽。生活的态度决定路的宽度。认真积极对待生活的人,生活回馈他的就是康庄大道;消极悲观地对待生活的人,他走的路可能是个死胡同。可能是我越来越悲观吧,我越来越觉得人活在世界上就是一种修行,Life is hard! 可能经历过了一些困难挫折,回过头来才发现原来这些都是些小事,你觉得困难的那些事情在别人眼里可能
2014-04-26 23:34:01 916 2
原创 Leetcode:Combinations 组合
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]
2014-04-22 23:49:15 882 3
原创 Leetcode:Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non
2014-04-21 21:11:58 602
原创 Leetcode:Generate Parentheses 生成有效括号对
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()
2014-04-20 17:00:09 1098
原创 Leetcode:Remove Duplicates from Sorted List 删除单链表中重复的节点
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.思路:用扫描
2014-04-18 17:24:20 637
原创 Leetcode:Triangle 数字三角形
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [
2014-04-14 17:18:45 1476
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人