`
淡淡的一抹
  • 浏览: 19075 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表
1 CSS声明方式 选择器{属性1:值1; 属性2:值2; ...; 属性n:值n;} 例如: /*body{background-color: black;}*//*页面背景设置为黑色*/ /*如果属性的值由多个单词组成,就必须在值上加引号*/ table{font-family: "sans serif"}/*所有表格字体为sans serif*/ /*如果要改变多个属性,可以用分号对多个属性的定义进行分割*/ p{background-color: black; color: red} 2 CSS中的单位 (1)数值单位 像素 px 12px相对大小 ...

Maximum Subarray

题目描述 Find 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 [4,−1,2,1] has the largest sum = 6. 解题思路 本问题是一个最大子串和问题,利用Kadane算法解决,时间复杂度为O(n)。但是在解决本题时需要注意Kadane算法只能解决有正数时的问 ...

Maximum Subarray

题目描述 Find 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 [4,−1,2,1] has the largest sum = 6. 思路(1) 从首元素开始,依次计算和后面值的和,并取最大值;直到进行到最后一个元素。但是这种方法超时,时间复杂度为O(n),需要寻找更加有效的方法。 ...

Roman to Integer

题目 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 思路 首先,学习一下罗马数字,参考罗马数字 罗马数字是最古老的数字表示方式,比阿拉伯数组早2000多年,起源于罗马 罗马数字有如下符号: 基本字符 I V X L C D M 对应阿拉伯数字 1 5 10 50 100 500 1000 计数规则: 相同的数字连写,所表示的数等于这些数字相加得到的数,例如:III = 3小的数字在大的数字右边,所表示的数等于这些数字 ...
Given 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 duplicates in the array. Here are few examples. [1,3,5,6], 5 → 2 [1,3,5,6], 2 → 1 [1,3,5,6], 7 → 4 [1,3,5,6], 0 → 0 package l ...

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? 1 自己的代码:运行并不成功,相对于对每个小于n的元素进行了两倍的操作,超时。 package leetcode; public class ClimbingStairs { public int climbStairs(int n) { if(n ...

Single Number II

Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 1 自己的代码 package leetcode; import java.util.Arrays; public class SingleNumberII { ...
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. package leetcode; class ListNode { int val; ListNode next; ListNode(int x) { ...
1 API(Application Programming Interface):应用程序接口。 2 CSS(Cascading Style Sheets):层叠样式表。
[size=medium][/size]Given a binary tree     struct TreeLinkNode {       TreeLinkNode *left;       TreeLinkNode *right;       TreeLinkNode *next;     } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NU ...
Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3},    1     \      2     /    3 return [1,3,2]. 思路:二叉树的中序遍历 package leetcode; import java.util.ArrayList; import java.util.List; public class BinaryTreeInorderTraversal { public ...
Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3},    1     \      2     /    3 return [1,2,3]. 思路:二叉树的前序遍历 package leetcode; import java.util.ArrayList; import java.util.List; public class BinaryTreePreorderTraversal { public ...

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自己的代码 class ListNode { int val; ListNode next; ListNode(int x) { val = x; next = null; } } public class LinkedListCycle { public ...
题目描述:Given 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. 1自己的代码 注意:二分查找树的定义是,左子树节点均小于root,右子树节点均大于root! 分析:本题其实关键是递推过程的分析,n个点中每个点都可以作为root,当 i 作为root时,小于 i  的点都只能放在其左子树中,大于 i 的点只能放在右子树中,此时只需求出左、右 ...
题目描述: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 and sell one share of the stock multiple times). However, you may not engage in multiple transac ...
Global site tag (gtag.js) - Google Analytics