自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(42)
  • 资源 (5)
  • 收藏
  • 关注

原创 171. Excel Sheet Column Number

Given a column title as appear in an Excel sheet, return its corresponding column number.For example: 数字 字母 A -> 1 B -> 2 Z -> 26 AA -> 27 这题目使用递归就可以,但需要注意数组不是从0开始的。/**

2017-04-23 22:53:22 254

原创 168. Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 数字 字母 1 -> A 2 -> B 26 -> Z 27 -> AA 这题目使用递归就可以,但需要注意数组不是从0开始的。/

2017-04-23 21:53:36 289

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

2017-04-23 14:46:33 228

原创 258. Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one d

2017-04-20 23:14:40 252

原创 3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. 题目解读:给出一个字符串的最长连续不重复字符串。注意,dvdf 给出的结果是3! 所以基本思想就是:/** * @param {string} s * @return {number} */var len

2017-04-20 15:39:15 188

原创 111. Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 求二叉树最小深度,注意是叶子节点距离跟节点的最小深度。/** * Defin

2017-04-19 23:57:17 141

原创 104. Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 求二叉树的最大深度/** * Definition for a bina

2017-04-19 23:36:34 150

原创 520. Detect Capital

Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this word

2017-04-19 22:34:18 211

原创 557. Reverse Words in a String III

Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: “Let’s take LeetCode contest”

2017-04-19 22:14:28 164

原创 splice、split,slice区分

这几个函数非常容易混淆,这里做一个对比用于Array 对象 功能 语法 参数 slice() arrayObject.slice(start,end) 返回一个新的数组,包含从 start 到 end (不包括该元素)的 arrayObject 中的元素。 splice() arrayObject.splice(index,howmany,item1,…..,itemX

2017-04-10 22:17:52 221

原创 541. Reverse String II

Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them.

2017-04-10 19:02:30 136

原创 344. Reverse String

Write a function that takes a string as input and returns the string reversed. Example: Given s = “hello”, return “olleh”. 这个题目如果使用JS的数组就很方便,因为数组有一个reverse 的方法。var reverseString = function(s) {

2017-04-10 17:54:13 132

原创 167. Two Sum II - Input array is sorted

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers suc

2017-04-10 11:54:31 146

原创 283. Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your funct

2017-04-10 11:14:45 133

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

2017-04-10 11:00:42 159

原创 203. Remove Linked List Elements

Remove all elements from a linked list of integers that have value val. 这个题目本想采用递归的方法,但是发现当前节点的前一个节点不好获取,所以采用非递归的方法。 在while循环里,每次判断当前节点的下一个节点值是否为所需值,然后删除起来就比较方便了/** * Definition for singly-linke

2017-04-09 23:00:50 156

原创 83. Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once. 这个题目采用了两种方法,一种递归,一种循环,其实原理都差不多。就是一个个找下一个的值是否和当前节点的值相同,若相同则删除,若不同,则继续检查下一个节点。//方法一var deleteDuplicates = fu

2017-04-09 21:04:14 264

原创 109. Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 这个题目和 108 很像,只是108本身就是有序数组转化为平衡二叉树,这里是链表转化为平衡二叉树,所以首先的想法就是把有序链表转化为有序数组,在使用 108 的函数得到答案。

2017-04-09 16:23:11 320

原创 108. Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题目是说将一个排好序的数组变成一个平衡二叉树,那么采用递归的思想就是: 当数组为空,则返回空,当数组长度为1,则返回这一个元素所创造的TreeNode,当数组长度大于1,那么就将数组分成两个部分,

2017-04-09 12:54:12 235

原创 236. Lowest Common Ancestor of a Binary Tree

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. 注意这里是普通的二叉树,没有顺序的,所以就要老老实实的查找。 如果跟节点和要查找的节点为空,就返回空,如果要查找的节点不存在于左边,就在右边找,如果不存在于右边,就在左边找,否则就是一左一右,那么就返回当前跟节

2017-04-08 23:51:53 134

原创 235. Lowest Common Ancestor of a Binary Search Tree

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. 因为是二叉查找树,所以比跟节点大的都在右边,比跟节点小的都在左边,这样子找起来就会方便些。/** * Definition for a binary tree node. * funct

2017-04-08 23:40:45 119

原创 226. Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1 这个是二叉树,先去复习一下二叉树的遍历方法:前序、中序、后序遍历都采用的是递归函数的方法,那么这里调换左右树枝也可以采用递归函数的方法。/** * Def

2017-04-03 22:01:31 125

原创 503. Next Greater Element II

Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the first grea

2017-04-03 17:12:38 240

原创 496. Next Greater Element I

You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2. T

2017-04-03 16:46:38 190

原创 485. Max Consecutive Ones

Given a binary array, find the maximum number of consecutive 1s in this array. 这个没什么还说的,按位计算。突然想到还可能有一个方法,按照splict把字符串分开,取最长的。哈哈/** * @param {number[]} nums * @return {number} */var findMaxConse

2017-04-03 16:15:32 186

原创 476. Number Complement

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note: The given integer is guaranteed to fit within the range of a 32-b

2017-04-03 13:20:36 190

原创 190. Reverse Bits

Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110

2017-03-18 14:52:24 237

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

2017-03-16 18:44:29 170

原创 461. Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note: 0 ≤ x, y < 231.

2017-03-16 15:57:40 337

原创 500. Keyboard row

Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below. 拿到这个题目感觉会比较简单,但是看着自己写的内容觉得步骤有点多啊~/** * @param {strin

2017-03-16 13:56:33 193

原创 448. Find All Numbers Disappeared in an Array

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could

2017-01-11 20:01:13 196

原创 387. First Unique Character in a String

Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.//Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note: You may assume

2016-12-04 16:51:11 166

原创 349/350. Intersection of Two Arrays

Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return[2]. Note: - Each element in the result must be unique. - The

2016-12-04 16:12:03 162

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

2016-12-03 20:21:18 190

原创 263. Ugly Number

Write a program to check whether a given number is an ugly number.

2016-12-02 22:57:14 160

原创 121. Best Time to Buy and Sell Stock

Say you have an array for which the ith 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 and sell one share of the stock),

2016-12-02 22:34:28 179

原创 231./ 326. /342. Power of Four/ Three /Two

Given an integer (signed 32 bits), write a function to check whether it is a power of 4/3/2

2016-12-01 19:01:46 207

原创 leetcode刷题记录

这个月开始刷leetcode,很认真的写,完了还纪录note,今天才发现原来写过的题目是不会保存的啊!所以想在这里记录一下,也算一种监督学习和进步吧~

2016-11-30 19:58:12 249

原创 JavaScript定时器(setInterval & setTimeout )

setInterval和setTimeout是干什么的? JS 中设置延时的函数主要有两个:setInterval和setTimeout。这两个函数的区别在于: setInterval表示的是循环执行,执行无数次直至清除循环 setTimeout表示的是延迟执行,只执行一次。 这两个函数分别对应两个清除函数: clearTimeout(对象)//清除已设置的setTime

2016-11-17 22:53:43 845

原创 HTML外部文件引入

HTML中的引入最好都用相对路径,以免更换服务器或移动更目录时发生错误。1. 图片or视频引入<img src="img/smile.jpg">//图片在同层文件夹【img】中。<video src="/video/movie.mp4" controls="controls">your browser does not support the video tag</video>//文件在下层文件

2016-11-08 12:35:03 2828

Axure for mac

Axure下载,亲测可用,功能齐全。下载下来直接解压,安装时一直下一步就可以了。

2014-12-06

java四级模拟试卷

java四级模拟试卷,内含详细的题目,word格式,亲测可用。希望有助于大家考试通过。

2014-04-26

USACO答案name that number

USACO答案,采用C++写的,题目是:name that number.

2013-12-12

emu8086汉化

emu8086汉化 将汉化文件夹内汉化版emu8086.exe文件拷贝到安装目录,替换原来的英文版即可。

2013-03-20

how to think in python

python入门书,比较基础的 ,新手或者没有接触过python的人建议读一读

2012-03-10

空空如也

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

TA关注的人

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