Yvan Jiang的专栏


Non-decreasing Array 非递减数列

#include <iostream> #include <vector> using namespace std; class Solution { public: bool checkPossi...

2018-09-26 17:00:15

阅读数 50

评论数 0


/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {}...

2018-09-25 11:12:31

阅读数 53

评论数 0

Leetcode Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra spac...

2015-09-27 09:50:02

阅读数 415

评论数 0

Leetcode Peeking Iterator

Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- i...

2015-09-25 09:37:43

阅读数 281

评论数 0

Leetcode Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at a...

2015-08-28 10:18:15

阅读数 241

评论数 0

Leetcode Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve ...

2015-08-27 18:18:53

阅读数 167

评论数 0

Leetcode Sort List

Sort a linked list in O(n log n) time using constant space complexity. 单链表排序问题,下面用插入排序的方法。 /** * Definition for singly-linked list. * struct Li...

2015-08-09 16:47:20

阅读数 209

评论数 0

Leetcode Largest Number

Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest form...

2015-08-08 21:05:43

阅读数 243

评论数 0

Leetcode 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 ...

2015-07-31 10:06:24

阅读数 234

评论数 0

Leetcode Next Permutation

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not po...

2015-07-25 12:40:34

阅读数 206

评论数 0

Leetcode 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 ...

2015-07-21 14:20:09

阅读数 229

评论数 0

Leetcode Subsets

Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must be in non-descending order.The solution ...

2015-07-17 10:13:20

阅读数 196

评论数 0

Leetcode Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->...

2015-07-15 16:58:03

阅读数 191

评论数 0

Leetcode Implement Queue using Stacks

Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue.pop() -- Removes the element from in fr...

2015-07-15 16:34:00

阅读数 234

评论数 0

Leetcode Implement Stack using Queues

Implement the following operations of a stack using queues. push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack....

2015-07-13 17:21:42

阅读数 291

评论数 0

Leetcode Summary Ranges

Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2",&...

2015-07-10 15:02:45

阅读数 210

评论数 0

Leetcode Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your m...

2015-06-19 15:27:18

阅读数 335

评论数 0

Leetcode LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get...

2015-06-07 16:52:48

阅读数 240

评论数 0

Leetcode Max Points on a Line

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 题意是给定N个点,找到共线的点最多有多少个,求固定一个点points[i],求points[...

2015-06-02 12:32:02

阅读数 259

评论数 0

Leetcode Contains Duplicate

Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the ...

2015-06-01 20:09:29

阅读数 250

评论数 0

取消 删除