自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

翻译 Leetcode 563. Binary Tree Tilt

Link to the problemIt is kinda intuitive that a recursive approach fits this problem perfectly. The main challenge lies in that we have to seek out a way to calculate the tilt of a node and sum all ...

2018-06-09 05:16:27 126

翻译 Leetcode 783. Minimum Distance Between BST Nodes

Link to the problemThe main idea was to apply in-order traversal to the BST. One key observation is that for a triad of nodes, one only has to compare the left and right child to its parent. There ...

2018-06-02 06:09:59 236

转载 Trie/ Leetcode 648. Replace Word

Relevant problem: Leetcode 648. Replace Word Using Trie, we can search the key in O(M)O(M)O(M) time, with a penalty on Trie storage requirement.An implementation:class TrieNode { // Initia...

2018-06-02 03:39:01 167

转载 Leetcode 733. Flood Fill

The description of the problem can be found here. It is a relatively simple problem. To solve this, we can simply use DFS to find all the neighboring tiles with the same color and color them with ne...

2018-05-31 12:40:22 157

翻译 347. Top K Frequent Elements

There are several ways to solve this problem. The approach that we are going to focus on here is called Bucket Sort. For details of Bucket Sort, you can visit this website: 点击打开链接. Here is a visualiza...

2018-05-20 02:51:27 98

翻译 Find the kth smallest element in two sorted array

The basic thought is as followsthe pseudo code will be as follows i <- k/2, j <- k/2 step <- k/4 while step > 0 if a[k/2] > b[k/2] i -= step j += step else i += step

2018-01-25 13:04:20 580

翻译 238. Product of Array Except Self

The main idea for this problem is to separate the multiplication into 2 parts— one before the number and one after the number. Therefore, we can solve this problem in two iterations. class Solution {

2018-01-03 13:46:15 112

翻译 637. Average of Levels in Binary Tree

It is really easy to implement this in a BFS manner. The only challenge lies in how to make sure that we are only counting the node that we need. A quick solution is to get the size of the queue every

2017-11-29 13:45:23 136

翻译 Split Linked List in Parts

This is a fairly easy problem The main idea is to first find the length of the linked list, and then it is easy to find the length of sub linked list. Figuring out all the cases can be somewhat chal

2017-11-28 13:54:01 177

翻译 Implementation of linked list in C

There is a caveat here, which requires us to use a double pointer for the head, otherwise, we will only update the local copy of head. bool insertInFront(IntElement **head, int data){ IntElement *n

2017-11-28 12:51:30 177

翻译 Insert at the front of a linked list

Suppose that every node contains an integer datatypedef struct IntElement{ struct IntElement *next; int data;}IntElement;First, we consider inserting a node at the head of the linked list.

2017-11-28 12:49:48 141

翻译 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-11-22 12:27:18 130

翻译 226. Invert Binary Tree

Invert a binary tree.First of all, consider recursive solution./** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right;

2017-11-21 14:18:23 124

翻译 442. Find All Duplicates in an Array

Find all Duplicates in an Array with time complexity O(n)

2017-11-20 12:55:20 123

空空如也

空空如也

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

TA关注的人

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