- 博客(35)
- 资源 (3)
- 收藏
- 关注
原创 leetcode 66. Plus One
题目Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.解public class Solution {
2016-05-31 15:30:31 325
原创 leetcode 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 is symmetric: But the following is not:解/** * Definition for a binary tre
2016-05-31 14:47:17 327
转载 java:equals与hascode( )
Java中的equals方法和hashcode方法是Object中的,所以每个对象都是有这两个方法的,有时候我们需要实现特定需求,可能要重写这两个方法。1.区别eqauls()和hashcode()方法是用来在同一类中做比较用的,尤其是在容器里如set存放同一类对象时用来判断放入的对象是否重复。这里我们首先要明白一个问题: 1,equals()相等的两个对象,hashcode()一定相等,equ
2016-05-31 14:19:04 492
原创 leetcode 27. Remove Element
题目Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.The ord
2016-05-31 11:11:18 278
转载 leetcode 110. Balanced Binary Tree
题目Given 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 every node never differ b
2016-05-31 10:28:43 322
转载 leetcode 198. House Robber
原文链接:http://bluereader.org/article/125400253题目You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you fro
2016-05-30 17:55:50 354
转载 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. You may
2016-05-30 16:26:15 299
原创 leetcode 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.解/** * Definition for singly-linked list. * public class
2016-05-27 17:24:06 272
原创 leetcode 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?解//采用DP的办法public class Solution {
2016-05-27 15:02:01 280
转载 leetcode 202. Happy Number
题目Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of
2016-05-27 14:25:00 363
原创 java.lang.Math类中包含基本的数字操作
Math类: 1,java.lang.Math类中包含基本的数字操作,如指数、对数、平方根和三角函数。 2,java.math是一个包,提供用于执行任意精度整数(BigInteger)算法和任意精度小数(BigDecimal)算法的类。 3,java.lang.Math类中包含E和PI两个静态常量,以及进行科学计算的类(static)方法,可以直接通过类名调用。函数public
2016-05-27 11:08:33 1000
原创 leetcode 326. Power of Three
题目Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion?解1 (递归,成功)public class Solution { public boolean isPowerOf
2016-05-27 10:31:06 302
原创 leetcode 191. Number of 1 Bits
题目Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 00000000
2016-05-26 18:07:04 287
转载 leetcode 94. 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 trivial, could you do it iteratively?
2016-05-26 10:24:18 369
原创 leetcode 318. Maximum Product of Word Lengths
题目Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case let
2016-05-25 14:35:02 374
原创 leetcode 144. Binary Tree Preorder Traversal
题目Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, return [1,2,3].解(非递归方法)/** * Definition for a binary tree node. * public clas
2016-05-25 13:38:20 309
转载 leetcode 343. Integer Break
题目Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return
2016-05-25 11:28:41 309
转载 leetcode 347. Top K Frequent Elements
题目Given a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number of unique e
2016-05-25 10:37:39 293
原创 leetcode 319. Bulb Switcher
题目There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off
2016-05-23 15:04:36 290
原创 leetcode 122. Best Time to Buy and Sell Stock II
题目Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one a
2016-05-23 14:31:29 277
原创 leetcode 238. Product of Array Except Self
题目Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).For
2016-05-23 13:43:05 279
转载 ClassLoader的加载顺序
1.初始类加载器层次结构当JVM(Java虚拟机)启动时,会形成由三个类加载器组成的初始类加载器层次结构: bootstrap classloader | extension classloader | system classloader其中, 1>bootstrapclassloader-引导(也称为原始)类加载器,它负责加载J
2016-05-17 18:02:57 815
转载 Java:Collection与Collections的区别
1.Collection原文链接:http://pengcqu.iteye.com/blog/492196java.util.Collection 是一个集合接口。它提供了对集合对象进行基本操作的通用接口方法。Collection接口在Java 类库中有很多具体的实现。Collection接口的意义是为各种具体的集合提供了最大化的统一操作方式。 Collection ├List │├Link
2016-05-17 17:29:42 686
转载 Java多线程
1.Java多线程传统实现方式原链接地址:http://blog.csdn.net/kingzone_2008/article/details/44571181public class TraditionalThread { public static void main(String[] args) { /* * 方法1:覆盖父类Thread的run方法
2016-05-17 11:40:54 460
原创 Java的12种设计模式
1.简单工厂 1.1简单工厂功能类编辑步骤 1>定制抽象产品接口,如ICar。 2>定制具体产品子类,如TopCar,MidCar,LowCar。 3>定制工厂类,如CarSimpleFactory。1.2简单工厂类的特点 它是一个具体的类,非接口或抽象类。其中一个重要的create()方法,利用if…else或switch开关创建所需产品,并返回。1.3工厂类静态crea
2016-05-16 18:05:56 1892
原创 CSS——(CSS样式规则,CSS样式表单,选择器,常用的CSS属性)
CSS(Cascading Style Sheets,层叠样式表单)是由W3C所提出,主要的用途是控制网页的外观,也就是定义网页的编排,显示,格式化及特殊效果,有部分功能与HTML重叠。1.CSS样式规则与选择器CSS样式表单是由一条一条的样式规则(style rule)所组成,而样式规则包含选择器(selector)与声明(declaration)两个部分:选择器{属性:值[;属性:值[; …]]
2016-05-13 17:34:18 4646 1
原创 JavaScript——3(事件处理与实用范例)
1.事件驱动模式:例如用户单击按钮,改变窗口大小,移动窗口,加载网页等,这些事件发生时,该窗口就会传送信息给系统,然后系统会处理信息传送给其他关联的窗口,这些窗口再根据信息作做出适当的处理,此种工作模式称为事件驱动(event driven)。2.事件的类型:load,unload,click,mouseover等简单的传统事件; 传统事件; DOM事件; 触控事件;3.事件处理程序方式1
2016-05-13 14:43:17 562
原创 JavaScript——2(对象)
1,对象(Object)或实例(instance):在JavaScript中,对象则是数据与程序代码的组合,它可以是整个应用程序或整个应用程序的一部分。 2,属性(property)或字段(filed):是用来描述对象的特质。 3,方法(method):是用来执行对象的动作。 4,事件(event):是在某些情况下发出特定信号警告。 5,类(class):是对象的分类,就像对
2016-05-13 12:07:35 8057
原创 JavaScript——1(基本语法,类型,变量与运算符,控制流程,函数)
一.JavaScript的基本语法1,JavaScript是一种应用广泛的浏览器端Scripts。 2,JavaScript并没有规定每条程序语句的结尾一定要加上分号(;)。 3,函数名称的开头建议以动词表示,例如initializeComponent,closeDialog等。 4,事件处理程序名称的结尾建议以EventHandler表示, 例如 mouseEventHandler。
2016-05-12 16:22:49 1066
转载 Java:Map与HashMap,Hashtable,HashSet比较
Java:Map与HashMap,Hashtable,HashSet比较原文链接 HashMap和Hashtable两个类都实现了Map接口,二者保存K-V对(key-value对);HashSet则实现了Set接口,性质类似于集合。HashTable和HashMap区别第一,继承的父类不同。Hashtable继承自Dictionary类,而HashMap继承自AbstractMap类。但二者都实现
2016-05-04 11:52:19 463
转载 Java:String、StringBuffer和StringBuilder的区别
Java:String、StringBuffer和StringBuilder的区别原文链接1 StringString:字符串常量,字符串长度不可变。Java中String是immutable(不可变)的。String类的包含如下定义:/** The value is used for character storage. */ private final char value[]; /**
2016-05-04 10:57:13 452
原创 回文数的判断
回文数的判断定义 1,“回文”是指正读反读都能读通的句子,它是古今中外都有的一种修辞方式和文字游戏,如“我为人人,人人为我”等。在数学中也有这样一类数字有这样的特征,成为回文数(palindrome number)。 2,设n是一任意自然数。若将n的各位数字反向排列所得自然数n1与n相等,则称n为一回文数。例如,若n=1234321,则称n为一回文数;但若n=1234567,则n不是回文数
2016-05-04 10:30:30 3616
原创 HTML——7(窗体与后台处理)
窗体与后台处理1.建立窗体——<form>,<input>元素窗体(form)可以提供输入接口,让用户输入数据,然后将数据传回web服务器,以做进一步的处理。<form method="post" action="handle.php"><form method="post" action="mailto:jeanchen@mail.lucky.com.tw"><input>元素用来在窗体中插入输
2016-05-03 17:32:21 6875
原创 HTML——6(表格)
表格1.建立表格——<table>,<tr>,<td>,<th>元素<body> <table border="1"> <tr> <th>人物素描</th> <th>角色</th> <th>介绍</th> </tr> <tr> <td><img src="piece1.jpg" width="
2016-05-03 16:44:54 4571
原创 HTML——5(图片)
图片1.图片的高度,宽度与框线 <body> <img src="jp3.jpg" height="315" width="370"> <img src="jp3.jpg" height="158" width="185" border="10"> </body>2.图片的对齐方式,替代文字 align 的对齐方式有left,right,middle,top,bottom
2016-05-03 16:18:47 443
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人