自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Leetcode 396. Rotate Function

O(n) Math solution./** * F(k) = 0 * Bk[0] + 1 * Bk[1] + ... + (n-1) * Bk[n-1] * = 0 * Bk-1[n-1] + 1 * Bk-1[0] + ... + (n-1) * Bk-1[n-2] * F(k-1) = 0 * Bk-1[0] + 1 * Bk-1[1] + ... +

2017-04-06 12:24:25 317

原创 Leetcode 119. Pascal's Triangle II

public class Solution { public List getRow(int rowIndex) { List list = new ArrayList(); if (rowIndex < 0) return list; for (int i = 0; i < rowIndex + 1; i++) { list

2017-04-06 11:15:39 211

原创 Leetcode 118. Pascal's Triangle

public class Solution { public List> generate(int numRows) { List> res = new ArrayList>(); if (numRows < 0) { return res; } List level

2017-04-06 11:14:52 212

原创 Leetcode 347. Top K Frequent Elements

Data structure used, hash table and min heap.A hashmap to save every element along with its frequency for the input data.A min heap to save top k most frequent map entry, comparing by map.value th

2017-04-06 03:38:05 224

转载 Leetcode 160. Intersection of Two Linked Lists

Assume the length of the intersection part is x, length of list a l1, and length of list b is l2.Then l1 + l2 = l2 + l1 => l1 + l2 - x = l2 + l1 - x.If tow lists have no intersection, then two poi

2017-04-03 06:10:47 266

原创 Leetcode 414. Third Maximum Number

public class Solution { public int thirdMax(int[] nums) { // Hashset to remove all duplicate elements HashSet set = new HashSet(); for (int num : nums) set.add(

2017-04-03 00:40:25 209

原创 Leetcode 155. Min Stack

O(nlogN) PriorityQueue.public class MinStack { PriorityQueue minHeap; Stack stack; /** initialize your data structure here. */ public MinStack() { minHeap = new PriorityQueue

2017-04-02 04:34:57 320

原创 Leetcode 380. Insert Delete GetRandom O(1)

Using ArrayList's get function to implement getRandom() in constant time, and a hashmap to save the pair.So we need to make sure the index of the last element always equals to the size of the list

2017-04-02 02:54:23 413

原创 Leetcode 42. Trapping Rain Water

/** * To sum up total trapping water, we need to know how many water can be trapped by each bar after raining. * The amount of trapping water for each bar is calculated by min(maxSeenLeft, maxSeenRi

2017-04-01 06:36:35 257

原创 Leetcode 206. Reverse Linked List

Iterative approach.public class Solution { public ListNode reverseList(ListNode head) { ListNode newHead = null; while (head != null) { ListNode next = head.next;

2017-04-01 05:35:30 208

空空如也

空空如也

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

TA关注的人

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