自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(71)
  • 收藏
  • 关注

原创 graphics参考技术文章存档

学computer graphics过程中参考的技术文章存档

2017-11-15 04:37:34 325

原创 [LeetCode]206. Reverse Linked List

注意递归的解法。

2017-08-14 10:49:50 243

原创 [LeetCode]160. Intersection of Two Linked Lists

重点在于两个list的长度。如何可以巧妙地使得两个不同长度的list的指针遍历到同一个位置上去。Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A:

2017-08-11 15:13:31 276

原创 [LeetCode]237. Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value

2017-08-11 11:08:03 225

原创 [LeetCode]141. Linked List Cycle

Two pointers + Linked list题目。很容易想到的方法是用hashSet来进行存储。而要用到O(1)的空间的话,则需要两个指针,一快一慢,若有circle,终会相遇。The fast runner will eventually meet the slow runner. Why? Consider this case (we name it case A) - The f

2017-08-11 10:53:43 261

原创 [LeetCode]173. Binary Search Tree Iterator

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next()

2017-08-10 09:57:01 210

原创 [LeetCode]520. Detect Capital

字母大小写对应的ASCII码:A65.B66.以此+1类推,a97.b98,以此1类推。Z是90

2017-08-08 17:57:04 281

原创 [LeetCode]459. Repeated Substring Pattern

Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase Engli

2017-08-08 16:56:09 215

转载 [LeetCode]404. Sum of Left Leaves 树的典型题目

Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.

2017-08-07 22:07:59 209

原创 [LeetCode]538. Convert BST to Greater Tree

Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.Exam

2017-08-07 16:29:34 227

原创 [LeetCode]389. Find the Difference

依旧是利用a^b^b==a的bit manipulation的特性。另一个方法则利用了将字母作为数组下标的方法。(从本质上来讲,在计算机里面,可以认为char就是int了,就是说可以把char当作int来用,如,作为数组下标。)Given two strings s and t which consist of only lowercase letters.String

2017-08-06 21:13:05 210

原创 [LeetCode]645. Set Mismatch

其实还是那种利用【数组元素->数组下标】来【转换正负性】的问题。The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in t

2017-08-06 20:58:59 827

原创 [LeetCode]204. Count Primes

Description:Count the number of prime numbers less than a non-negative number, n.public class Solution { public int countPrimes(int n) { int res=0; boolean[] prime = new bo

2017-08-06 19:53:37 217

原创 [LeetCode]Sliding Window Algorithm相关题目总结【重要】

滑动窗口算法的一些具体应用。subString的问题。https://leetcode.com/problems/find-all-anagrams-in-a-string/discuss/

2017-08-06 17:10:04 3492 1

原创 [LeetCode]594. Longest Harmonious Subsequence<HashMap>

We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1.Now, given an integer array, you need to find the length of its longest h

2017-08-04 16:37:22 249

原创 Java-HashMap踩坑小记

1.关于put()的返回值Object put(Object k, Object v)Puts an entry in the invoking map, overwriting any previous value associated with the key. The key and value are k and v, respectively.Returns nu

2017-08-04 12:08:13 608

原创 Java-String踩坑小记

1.equals和==的区别String str1="aa";String str2="aa";str1==str2返回的会是false,因为str1和str2里面存储的是其关联的对象在内存中的地址,而此时它们指向的是不同的地址,自然是不相同的。如果用str1.equals(str2) 返回的是true,因为比较的是关联的对象所存储的值。2.数组的遍历的实现用l

2017-08-04 11:58:20 306

原创 [LeetCode]349. Intersection of Two Arrays

Binary Search很简单的一道题,但是犯了好多错误。要求:再从头写一遍,要求一次bug-free AC.https://leetcode.com/problems/intersection-of-two-arrays/description/Given two arrays, write a function to compute their interse

2017-08-03 16:50:28 330

原创 [LeetCode]374. Guess Number Higher or Lower<Binary Search>

注意亮点。1、low=mid+1; high=mid;2、mid=(high-low)/2+low; 不可以用mid=(low+high)/2,因为加了以后数据有可能会溢出。We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to gu

2017-08-03 16:03:53 252

原创 [LeetCode]268. Missing Number

Point: a^b^b=a.two xor operations with the same number will eliminate the number and reveal the original number. 两个相同的数异或结果为0。一个数和两个相同的数异或的结果为它自身。Given an array containing n distinct numbers

2017-08-03 14:33:00 216

原创 [LeetCode]628. Maximum Product of Three Numbers

排序过后,依次讨论前三个,后三个,以及后两个跟第一个,前两个跟最后一个。注意负数!!Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6

2017-08-02 20:21:53 320

原创 [LeetCode]169. Majority Element

Array. Divide and Conquer. Bit manipulation.Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume tha

2017-08-01 17:37:00 204

原创 [LeetCode]122. Best Time to Buy and Sell Stock II

Greedy+Array. Easy mode.我的解法太啰嗦了,标准答案才是真正用到了“greedy”的精髓。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.

2017-08-01 17:11:54 314

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

Two Sum的变种。增加了新的条件,给出的数组元素是按照增序排列的。在新条件下不需要再用到HashMap,一定要利用好“sorted in ascending order”这个新特性。思路:Two Pointers + Binary Search。从首尾开始逼近我们想要的值……同时注意需要存放的下标的值。Given an array of integers that is a

2017-08-01 16:27:40 209

原创 [LeetCode]238. Product of Array Except Self

Array类型的Medium题目。计算数组里除了自己的元素的乘积。不允许用到除法。我们想,对于某一个数字,如果我们知道其前面所有数字的乘积,同时也知道后面所有的数乘积,那么二者相乘就是我们要的结果。不需要用到两个数组来存放结果,用一个常数来存放一边的值。Given an array of n integers where n > 1, nums, return an arr

2017-08-01 16:11:50 232

原创 [leetCode]565. Array Nesting

A zero-indexed array A consisting of N different integers is given. The array contains all integers in the range [0, N - 1].Sets S[K] for 0 S[K] = { A[K], A[A[K]], A[A[A[K]]], ... }.Sets S

2017-08-01 09:26:48 212

原创 [LeetCode]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 you

2017-07-31 17:00:00 221

转载 [LeetCode]646. Maximum Length of Pair Chain<DP>

You are given n pairs of numbers. In every pair, the first number is always smaller than the second number.Now, we define a pair (c, d) can follow another pair (a, b) if and only if b . Chain

2017-07-31 16:04:53 543

原创 [LeetCode]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.Coul

2017-07-31 14:58:17 210

原创 [LeetCode]1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same 

2017-07-31 10:28:24 215

原创 [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?Note: Given n will be a positive

2017-07-29 20:35:49 194

原创 [LeetCode]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),

2017-07-29 20:18:38 176

原创 [LeetCode]198. House Robber

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 from robbing each of them is that adjacent house

2017-07-29 19:43:09 246

原创 [LeetCode]53. 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] ha

2017-07-29 08:26:37 173

转载 [LeetCode]303. Range Sum Query - Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRange

2017-07-28 20:49:32 241

原创 [LeetCode]547. Friend Circles

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, the

2017-07-27 20:51:43 431

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

2017-07-27 17:43:10 249

原创 [LeetCode]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./** * Definition for a binary

2017-07-27 17:05:10 233

原创 [LeetCode]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./** * Definition for a binary tree node. * public class TreeNode { * int val; * T

2017-07-27 16:51:36 179

原创 [LeetCode]112. Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum

2017-07-27 15:33:30 190

空空如也

空空如也

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

TA关注的人

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