LeetCode
文章平均质量分 73
IronYoung
字节跳动 AI Lab | 图形图像 | 机器学习 | weibo:@iamironyoung
展开
-
【LeetCode从零单刷】Linked List Cycle I & II
菜鸡从零单刷 LeetCode 系列原创 2015-04-13 09:42:34 · 997 阅读 · 2 评论 -
【LeetCode从零单刷】H-index I & II
题目:Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikip原创 2015-11-01 10:25:25 · 885 阅读 · 0 评论 -
【LeetCode从零单刷】Kth Smallest Element in a BST
题目:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Follow up:Wh原创 2015-10-30 10:36:37 · 1477 阅读 · 2 评论 -
【LeetCode从零单刷】Symmetric Tree
题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3原创 2015-10-29 22:02:12 · 1196 阅读 · 2 评论 -
【LeetCode从零单刷】Number of 1 Bits & Power of Two
菜鸡单刷LeetCode系列!原创 2015-04-08 09:53:58 · 746 阅读 · 0 评论 -
【LeetCode从零单刷】Populating Next Right Pointers in Each Node I & II
菜鸡从零单刷 LeetCode 系列原创 2015-04-12 23:34:01 · 906 阅读 · 0 评论 -
【LeetCode从零单刷】Find Peak Element
题目:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks原创 2015-10-14 20:53:05 · 1409 阅读 · 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 depth of the two subtrees of every node ne原创 2015-10-14 21:18:57 · 1418 阅读 · 0 评论 -
【LeetCode从零单刷】Different Ways to Add Parentheses
题目:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are+, - and *.Example原创 2015-11-15 22:20:07 · 853 阅读 · 0 评论 -
【LeetCode从零单刷】Nim Game
【LeetCode从零单刷】Nim Game原创 2015-10-13 16:42:16 · 9261 阅读 · 0 评论 -
【LeetCode从零单刷】Container With Most Water
题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and原创 2015-10-13 23:35:59 · 687 阅读 · 0 评论 -
【LeetCode从零单刷】Spiral Matrix II
题目:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9原创 2015-10-13 21:49:18 · 1307 阅读 · 0 评论 -
【LeetCode从零单刷】Rotate Image
题目:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?解答:一开始想的很复杂,希望找到一个通式应对所有角度的旋转。所有的细节写在《【图像处原创 2015-10-13 22:13:56 · 1546 阅读 · 0 评论 -
【LeetCode从零单刷】Intersection of Two Linked Lists
题目: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: a1 → a2 ↘原创 2015-11-13 17:54:49 · 1375 阅读 · 0 评论 -
【LeetCode从零单刷】Swap Nodes in Pairs
LeetCode从零单刷原创 2015-10-11 10:33:38 · 737 阅读 · 0 评论 -
【LeetCode从零单刷】Binary Tree Level Order Traversal I & II
题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9原创 2015-11-01 10:53:39 · 746 阅读 · 0 评论 -
【LeetCode从零单刷】Permutations
LeetCode 从零单刷原创 2015-10-13 09:39:04 · 678 阅读 · 0 评论 -
【LeetCode从零单刷】Combinations & Combination Sum 系列
题目:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3],原创 2015-10-31 22:35:41 · 2607 阅读 · 0 评论 -
【LeetCode从零单刷】Ugly Number I, II & Super Ugly Number
LeetCode从零单刷原创 2015-10-11 10:17:06 · 4673 阅读 · 0 评论 -
【LeetCode从零单刷】Best Time to Buy and Sell Stock I, II, With Cooldown
菜鸡从零单刷 LeetCode 系列!原创 2015-04-08 09:16:15 · 922 阅读 · 0 评论 -
【LeetCode从零单刷】Bulb Switcher
题目:There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turni原创 2015-12-19 16:50:27 · 9016 阅读 · 0 评论 -
【LeetCode从零单刷】Unique Binary Search Trees I & II
菜鸡从零单刷 LeetCode 系列!原创 2015-04-08 12:01:04 · 711 阅读 · 0 评论 -
【LeetCode从零单刷】Kth Largest Element in an Array
题目:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, retur原创 2015-11-28 20:55:39 · 1378 阅读 · 1 评论 -
【LeetCode从零单刷】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.解答:非常无聊的一题。需要注意的是:叶子节点是自身不为 N原创 2015-11-28 20:24:35 · 1321 阅读 · 1 评论 -
【LeetCode从零单刷】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.解答:将一段有序序列转换为平衡二叉树,重要是递归。即中点作为根节点,小于部分作为左子树递归,大于部分作为右子树递归。这里的单链表给 “找中点” 造成了难题,原创 2015-11-28 21:42:54 · 903 阅读 · 0 评论 -
【LeetCode从零单刷】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 as001原创 2015-11-28 21:19:28 · 1524 阅读 · 0 评论 -
【LeetCode从零单刷】Merge Sorted Array
题目:Given two sorted integer arrays nums1 and nums2, merge nums2 intonums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal tom + n) to hol原创 2015-11-28 21:07:10 · 1263 阅读 · 1 评论 -
【LeetCode从零单刷】Perfect Squares
题目:Given a positive integer n, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because12 = 4 + 4 + 4; given原创 2015-11-28 19:38:52 · 2056 阅读 · 2 评论 -
【LeetCode从零单刷】Set Matrix Zeroes
题目:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight forward solution using O(mn) space is probabl原创 2015-11-01 09:38:57 · 1515 阅读 · 0 评论 -
【LeetCode从零单刷】Remove Duplicates from Sorted Array I & II
I 题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length.Do not allocate extra space for another array, you must do this in plac原创 2015-11-02 21:29:36 · 1366 阅读 · 0 评论 -
【LeetCode从零单刷】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 adjacen原创 2015-11-02 21:03:07 · 1545 阅读 · 0 评论 -
【LeetCode从零单刷】Search in Rotated Sorted Array I & II
I 题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array re原创 2015-11-02 23:18:12 · 1448 阅读 · 0 评论 -
【LeetCode从零单刷】Sort Colors
题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the intege原创 2015-09-21 19:38:17 · 706 阅读 · 0 评论 -
【LeetCode从零单刷】Valid Anagram
题目:Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.解答:不要被各种类型的原创 2015-09-13 19:45:59 · 589 阅读 · 0 评论 -
【LeetCode从零单刷】Convert Sorted Array to Binary Search Tree
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解答:解决树的问题,一般都会涉及到递归。class Solution {public: TreeNode* sortedArrayToBST(vector& nums) {原创 2015-09-13 21:48:41 · 539 阅读 · 0 评论 -
【LeetCode从零单刷】Binary Tree Preorder Traversal
菜鸡从零单刷 LeetCode 系列!原创 2015-04-12 23:17:46 · 678 阅读 · 0 评论 -
【LeetCode从零单刷】Remove Duplicates from Sorted List
菜鸡从零单刷 LeetCode 系列!原创 2015-05-13 11:42:02 · 1045 阅读 · 0 评论 -
【LeetCode从零单刷】Integer to Roman
菜鸡从零单刷 LeetCode 系列!原创 2015-05-13 10:48:06 · 927 阅读 · 0 评论 -
【LeetCode从零单刷】Single Number II
菜鸡从零单刷 LeetCode 系列!原创 2015-05-13 11:13:15 · 753 阅读 · 0 评论 -
【LeetCode从零单刷】Maximum Subarray
菜鸡从零单刷 LeetCode 系列!原创 2015-05-13 11:34:31 · 777 阅读 · 0 评论