- 博客(32)
- 资源 (3)
- 收藏
- 关注
原创 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,#,#,15,7},return its level order trav...
2018-12-30 17:27:41 239
原创 n queens ii(n皇后问题-只计数不保存)
n皇后问题(保存并返回所有的解决方案)题目描述Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.题目大意著名n皇后问题。n个皇后摆放在N x N的棋盘格中,使得横、竖和两个对角线方向均不...
2018-12-29 23:49:43 362
原创 n-queens(n皇后问题)
问题描述The n queens puzzle is the problem of placing n queens on an N x Nchessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle....
2018-12-28 16:03:31 3180
原创 Set Matrix Zeroes(矩阵置0)
题目描述Set MatrixGiven a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight forward solution using O(m n) space is pr...
2018-12-25 17:16:37 939
原创 Jump-Game
题目描述Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position....
2018-12-24 16:45:42 112
原创 寻找第一个丢失的正数
题目描述First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should run in O(n) time a...
2018-12-23 17:07:20 164
原创 截留雨水
类似问题:容器最大容水量题目描述Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example,Given[0,1,0,2,1,...
2018-12-23 15:44:08 370
原创 荷兰国旗问题(颜色排序问题)
题目描述Sort ColorsGiven an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will u...
2018-12-21 21:44:31 2165
原创 从有序数组中移除相等的数值
题目描述Remove Duplicates From Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for anoth...
2018-12-19 23:05:41 213
原创 工厂模式02之工厂方法模式
参考:Head First设计模式概述简单工厂模式实现了生成产品类的代码与客户端代码分离,在工厂类中可以添加生成产品的逻辑代码。但是简单工厂模式不符合“开放-封闭”原则。例如要加一个 新产品类,就要修改 工厂类 生成产品的逻辑代码,增加if-else判断。对于这个问题,工厂方法模式可以解决。定义工厂方法模式 定义了一个创建对象的接口,但由子类决定要实例化的类是哪一个。工厂...
2018-12-18 14:11:23 189
原创 工厂模式01之简单工厂
概念简单工厂可以理解为,定义一个工厂类,根据传入的参数不同而返回不同的实例,这些实例通常有共同的父类。虽然简单工厂经常会被使用,但是并不能算作是一种设计模式,反而更像是一种编程习惯。提出问题当我们创建产品类对象时,会使用到new操作符,但是代码绑着具体类的实例会导致代码更脆弱,更缺乏弹性。实例化这个活动不应该总是公开的进行。否则一旦有变化或扩展,就必须重新打开这段代码进行检查和修改。...
2018-12-17 20:14:28 168
原创 合并两个顺序链表
题目描述Merge Two Sorted ListsMerge 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.题目大意合并两个顺序排列的链表,并将新链表返回。新链表...
2018-12-17 16:14:47 1750
原创 二叉树遍历(前序)(递归+非递归)
题目Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes’ values.For example:Given binary tree{1,#,2,3},return[1,2,3].Note: Recursive solution is trivia...
2018-12-16 14:39:20 230
原创 Java EE Web应用开发方法
主要内容B/S编程模式简介HTML和HTTP动态web编程初识Servlet & JSPMVC设计模式初步讨论B/S编程模式简介Web服务器Web服务器接收客户端的请求并将结果返回客户端结果:HTML页面、图片、文件、……Web客户端Web客户端可以使用户向服务器提出请求,并向用户展现请求的结果浏览器知道如何与服务器通信,并能够解释HTML代码并展现...
2018-12-16 00:04:49 2751
原创 生成括号
题目Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:“((()))”, “(()())”, “(())...
2018-12-15 23:06:43 226
原创 Java EE架构概述
主要内容分布式多层应用Java EE容器Web Service支持打包应用开发角色Java EE APIs引子Java Platform, Enterprise Edition(Java EE)为设计、开发、装配和部署企业应用程序提供了一个基于组件的方法Java EE平台提供了:一个多层分布式应用模型可复用组件模型一个统一的安全模型灵活的事务控制Web Serv...
2018-12-15 00:18:44 1465
原创 二叉树遍历(中序)(递归+非递归)
Binary Tree Inorder Traversal(二叉树中序遍历)Given a binary tree, return the inorder traversal of its nodes’ values.For example:Given binary tree{1,#,2,3},return[1,3,2].Note: Recursive solution is triv...
2018-12-14 23:06:00 390
原创 搜索一个2D矩阵
Search A 2D Matrix(搜索一个2D矩阵)Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.Th...
2018-12-14 16:39:58 243
原创 唯一路径
Unique PathsA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to ...
2018-12-13 17:10:04 244
原创 平衡二叉树
Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of ever...
2018-12-12 19:30:25 108
原创 再谈装饰者模式(总结)
在之前的文章 浅谈装饰者模式+JAVA I/O中的装饰者模式 中,浅谈了一下装饰者模式,这篇文章来总结一下装饰者模式。装饰者模式遵循开放-关闭原则,即,类应该对扩展开放,对修改关闭;用运行时扩展来取代编译时继承;解决了继承滥用的问题;用对象组合的方式,做到在运行时装饰类,能够在不修改任何底层代码的情况下,给对象赋予新的职责。尽管继承威力强大,继承并不总是实现最有弹性和最好维护的设计。...
2018-12-11 14:46:48 147
原创 查找插入位置
Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no dupl...
2018-12-11 14:13:40 411
原创 博客体验优化
添加分类、标签、关于等页面以添加分类页面为例:在站点目录下,打开Git Bash Here,输入hexo new page "categories"之后在站点目录下的source文件夹下,会新增一个categories的文件夹,里面有一个index.md文件,打开如下title: categoriesdate: 2015-12-04 15:37:22type: "categori...
2018-12-10 16:37:38 490
原创 图片旋转
Rotate ImageYou 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?题目大意:给定一个NxN的2D矩阵代表一张图片。把这张图片旋转90°(顺时针方向)。提示:...
2018-12-09 23:27:38 374
原创 罗马数字转换成整型数字
Roman To IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.题目大意:给定一个罗马数字,把它转换成一个整型数字。输入的罗马数字保证是在1~3999范围内的。思路:(对照 整型数字转换成罗马数字)首先看罗马...
2018-12-07 21:08:24 1521
原创 春秋招聘 + 寒暑假实习 时间线
01秋季校招招聘季大概持续5-6个月,次年6月入职,部分已毕业回国的留学生也可提前入职。秋招规模大、岗位全、质量高,基本所有行业、企业都会开启招聘;招聘流程复杂且时间战线长,需要经过网申-性格测试-笔试-单面-群面-发Offer等5-10轮筛选秋招时间线7-8月 互联网大厂的提前批、正式校招开放;9-10月 秋招黄金月,快消、咨询、房地产等行业全面开启校招;11-12月 面试...
2018-12-07 13:01:56 4400 2
原创 唯一二叉搜索树
Unique Binary Search TreesGiven n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example,Given n = 3, there are a total of 5 unique BST’s.题目大意:给定一个数字n,有多少个结点...
2018-12-06 17:01:36 1098
原创 爬楼梯
Climbing StairsYou 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?题目大意:比方说你正在爬一个...
2018-12-05 20:38:21 157
原创 股票最大利润 I
Best Time To Buy and Sell StockSay you have an array for which the i th element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one a...
2018-12-04 23:23:27 835
原创 判断回文数字
Ppalindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If yu are thinking of converting the integer...
2018-12-03 20:59:15 1314 1
原创 最长子序列和
Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray...
2018-12-02 20:33:11 851
原创 相等二叉树
Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.题目...
2018-12-01 18:11:33 333
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人