自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

ass673556617的专栏

近期记录一些leetcode上的题目,以及平时遇到的一些问题

  • 博客(31)
  • 资源 (12)
  • 收藏
  • 关注

原创 Remove Duplicates from Sorted Array

Given 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 another array, you must do this in place with

2015-07-28 21:41:05 418

原创 个人博客进度记录

从当初有了做个人博客的想法到实施到现在,将近一周的时间。觉得做一样东西,最重要的一点是脑袋里面要想清楚做什么,要能够具体到细节的地方。

2015-07-28 21:15:31 549

原创 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

2015-07-28 20:53:46 373

转载 JSP 获取真实IP地址的代码

转载:http://www.jb51.net/article/21272.htm在JSP里,获取客户端的IP地址的方法是:request.getRemoteAddr(),这种方法在大部分情况下都是有效的。但是在通过了 Apache,Squid等反向代理软件就不能获取到客户端的真实IP地址了。如果使用了反向代理软件,用 request.getRemoteAddr()方法获取的

2015-07-26 15:18:01 2089

转载 mysql实现文章上一篇下一篇的sql语句

转载:http://www.111cn.net/database/mysql/66709.htm在mysql中查查询上一篇与下一篇只需要对数据进行按id排序之后,然后我们再进行asc或者desc最当前ID下一个就可以了,下面整理了一些例子。实现网站文章里面上一篇和下一篇的sql语句的写法。当前文章的id为 $article_id,当前文章对应分类的id是$cat

2015-07-26 00:46:59 6435 1

原创 java 用 _id 查找 MongoDB 下的数据

找网上的资料看了下增删改查,等日后补上。已经实现了数据的插入,现在想通过 _id属性来查找数据。一开始看到 类似 55b321df715cc162076eb466 这么一长串的内容觉得是string类型。但是发现并不能搜索到结果,在网上搜到了解决方案:String sid = "55b321df715cc162076eb466";sitem.put("_id", new Object

2015-07-25 14:29:02 1066

原创 MongoDB启动方法

最近在做个人博客,打算尝试下mongodb做数据库。记录下如何开启数据库的。1. 首先开启一个控制台,进入mongodb的安装目录的bin文件夹下,如图2.命令mongod --dbpath=数据库路径    路径自己选定就可以3.开启后会提示等待请求接入。可以用localhost:27017来查看状态这样就连上了。因为之前用的是My

2015-07-24 19:07:59 531

原创 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:"((()))", "(()())", "(())()", "()(())", "()()

2015-07-24 14:54:19 452

原创 Rectangle Area

Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the tota

2015-07-24 14:18:30 490

原创 3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c

2015-07-22 18:40:39 399

原创 Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va

2015-07-22 17:51:19 481

原创 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.改了好久,可是明明不难的啊。代码:package leetcode;import java.uti

2015-07-22 13:40:53 361

原创 Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st

2015-07-21 22:49:21 525

原创 Remove Nth Node From End of List

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

2015-07-21 19:43:34 530

原创 Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.总之不难,但是脑袋要清醒..代码:public class Solution { public String longestCommonPrefix(String[] strs) {

2015-07-21 14:31:48 479

原创 Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.搞了挺久一直没搞出来。看了网上的参考后知道是推导的公式写错了。如果是从高位往地位扫(也就是一次循环用s.charAt(i)由高往低),那么相邻元素之

2015-07-21 12:07:28 436

原创 Integer to Roman

Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.这道题直接上来硬写的,感觉有点没动脑筋。想起当时用java课上一道关于扑克牌的课后作业,应该写的灵活些。像本题,如果还需要写出后续的数字这种写法就不妥当了。我想

2015-07-21 00:45:12 405

原创 Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2015-07-20 17:08:37 390

原创 4Sum

实现的时候参考了http://blog.sina.com.cn/s/blog_71d59f9a01018dh3.html 的思路。Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadru

2015-07-20 15:52:08 413

转载 leetcode难度及面试频率

转自:http://blog.csdn.net/yutianzuijin/article/details/11477603       1Two Sum25arraysort   

2015-07-19 21:49:18 508

原创 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

2015-07-19 12:28:32 410

原创 Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.实现代码:public boolean isPalindrome02(int x) { String num= Integer.toString(x); if(num.length()>11 || num.charAt(0)=='

2015-07-19 11:19:03 363

原创 String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2015-07-19 00:32:04 452

原创 Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321这道题其实不难,重要的是对一些特殊值进行判断。如果输入数字为超过int范围的值该如何处理。例如:1534236469,反过来会超范围,但是在计算的过程中不会提示你已经越界了。我用的是一个Long

2015-07-18 22:45:15 343

原创 ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S

2015-07-18 10:30:42 467

原创 Longest Palindromic Substring

提述:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.写了一个算法,但是

2015-07-15 13:57:05 414

原创 Longest Substring Without Repeating Characters

实现思路参考了网上的内容。一开始的想法是通过一个嵌套循环计算每一位的最长子串,时间复杂度是O(n3)。在嵌套的第二个循环内,使用 map.containKey来判断当前是否存在值,存在的话跳出循环,不存在的话存入key。这个思路最大的问题是复杂度比较高。网上提供了 一种线性时间的解决方法,核心思想是当遇到重复的字符时,起点更新为重复字符的上一个位置。需要借助一个数组来保存上一个位置的信息。

2015-07-14 12:59:50 497

原创 Median of Two Sorted Arrays

leetecode 上的一道题: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)).实现代码:

2015-07-13 23:09:47 520

原创 python编程之 环绕卫星轨道

教材的第六章主要讲了下如何加载图片以及缩放,旋转等基本操作。用一个环绕卫星demo作为例子。因为没有找到素材,在实现的过程中飞船的环绕的中心点并不是画面中央,我觉得可能是素材的因素,如果有错误欢迎指出。没有按照书上的方法写飞船旋转的代码,而是基础的数学知识,根据当前位于圆心可以计算的角度。草图如下,对很简单。。实际进行编写的时候会根据你写的三角函数,位置会做一些调整,思路就是这

2015-07-08 22:51:22 5674 1

原创 python编程之 模拟时钟

运用画圆,画线的方法,以及一些数学知识做的一个demo。 对教材里的例子里的画时针的部分修改了下。需要注意的是远点选择在中央,而数字时钟的十二点位于远点的正上方。所以如果用三角函数来计算时针分针秒针的位置的时候需要对角度进行旋转。根据sin, cos函数的特点,将对应的角度-90 读得到的是所需要的结果。比如说位于第一象限,相对于远点,sin值要为负,cos值为正; 第二象限,sin 为正,

2015-07-08 19:09:37 2718

原创 python编程之bomb catcher 小游戏

一个简单的演示,综合了鼠标的输入、一些基本的图形绘制等等。当炸弹到达屏幕底端的时候如果没有抓住的话会丢掉性命。如果撞击到挡板,玩家就算抓住了炸弹,另一个炸弹也会落下。源代码如下:# -*- coding: utf-8 -*-"""Created on Tue Jun 30 23:42:49 2015@author: liuchang"""import pygame,

2015-07-01 17:40:02 1309

Unity3D Tetris 俄罗斯方块

在Umedy上找到一门Unity的入门课,跟着课程写了一个俄罗斯方块的游戏。涉及到unity的基本概念,以及particle模块。

2018-04-18

Angular4 英文教材 参考代码

这个是对应angular4那本英文教材的代码。我也是在网络上找到的,只是希望拿过来跟大家分享下,一起学习。我觉得angular对java基础还有注入依赖有经验的同学来说还是会觉得比较好接受。希望一起进步。

2017-11-07

Angular 股票管理

照着幕课网的内容写了一个demo。前端angular, 后端express, 样式Admin-LTE。只提供了查看的功能,修改跟添加功能不能同步到后端,等看完官网的表单部分再补充把。

2017-08-26

Angular4 Http

angular的http模块应用 参考教材以及代码 实现的youtube搜索框 启动: npm install, npm start

2017-08-10

angular form 表单例子

使用formbuilder创建一个表单

2017-07-19

angular4 教材 第二个inventory例子

还是基础的angular 的概念。没有加样式。

2017-07-07

angular4 教材 第一个reddit例子

angular4 教材第二章的例子 介绍基础的angular 用法

2017-07-05

Angular4 表单demo

angular 4 官方教程里的表单例子

2017-06-09

Angular4 官方英雄编辑器

照着angular4 教程写的,对于HTTP部分RXJS部分表示很迷。

2017-06-02

django 1.8 polls 例子

根据django 1.8 官方事例做的小demo

2015-10-02

个人博客jsp实现

用了基础的jsp,servlet。数据库采用mysql。算是课下练习把。实现了文章阅读,评论,点赞。

2015-08-06

空空如也

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

TA关注的人

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