
LeetCode
prayyojay
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 436. Find Right Interval 题解(C++)
Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is on the "righ原创 2016-11-02 16:25:59 · 894 阅读 · 0 评论 -
LeetCode 452. Minimum Number of Arrows to Burst Balloons 题解(C++)
here are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates donoor原创 2016-11-09 18:21:55 · 817 阅读 · 0 评论 -
LeetCode 387. First Unique Character in a String 题解(C++)
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.原创 2016-10-18 19:40:23 · 409 阅读 · 0 评论 -
LeetCode 453. Minimum Moves to Equal Array Elements 题解(C++)
Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.n原创 2016-11-09 09:57:06 · 759 阅读 · 0 评论 -
LeetCode 52. N-Queens II 题解(C++)
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions.原创 2016-10-27 22:22:23 · 415 阅读 · 0 评论 -
LeetCode 419. Battleships in a Board 题解(C++)
Given an 2D board, count how many different battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules:原创 2016-10-18 11:14:57 · 896 阅读 · 0 评论 -
LeetCode 12. Integer to Roman 题解(C++)
Given an integer, convert it to a roman numeral.原创 2016-10-27 14:04:35 · 377 阅读 · 0 评论 -
LeetCode 343. Integer Break 题解(C++)
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.原创 2016-10-17 20:30:55 · 426 阅读 · 0 评论 -
LeetCode 409. Longest Palindrome 题解(C++)
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.原创 2016-10-02 16:00:30 · 1148 阅读 · 0 评论 -
LeetCode 436. Find Right Interval 题解(C++)
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.原创 2016-11-07 19:54:10 · 437 阅读 · 0 评论 -
LeetCode 389. Find the Difference 题解(C++)
Given two strings s and t which consist of only lowercase letters. - String t is generated by random shuffling string s and then add one more letter at a random position. - Find the letter that was added in t原创 2016-10-01 22:31:44 · 515 阅读 · 0 评论 -
LeetCode 413. Arithmetic Slices 题解(C++)
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.原创 2016-10-15 21:26:22 · 952 阅读 · 0 评论 -
LeetCode 242. Valid Anagram 题解(C++)
Given two strings s and t, write a function to determine if t is an anagram of s.原创 2016-10-19 13:43:33 · 1575 阅读 · 0 评论 -
LeetCode 169. Majority Element 题解(C++)
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.原创 2016-10-19 14:41:46 · 720 阅读 · 0 评论 -
LeetCode 318. Maximum Product of Word Lengths 题解(C++)
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case letters.原创 2016-11-02 14:03:10 · 540 阅读 · 0 评论 -
LeetCode 319. Bulb Switcher 题解(C++)
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原创 2016-11-01 21:34:35 · 448 阅读 · 0 评论 -
LeetCode 283. Move Zeroes 题解(C++)
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.原创 2016-10-08 17:00:30 · 349 阅读 · 0 评论 -
LeetCode 260. Single Number III 题解(C++)
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.原创 2016-10-07 22:39:10 · 453 阅读 · 0 评论 -
LeetCode 268. Missing Number 题解(C++)
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.原创 2016-10-20 12:13:54 · 631 阅读 · 0 评论 -
LeetCode 350. Intersection of Two Arrays II 题解(C++)
Given two arrays, write a function to compute their intersection.原创 2016-10-20 10:23:00 · 502 阅读 · 0 评论 -
LeetCode 217. Contains Duplicate 题解(C++)
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 array, and it should return false if every element is distinct.原创 2016-10-20 09:50:33 · 437 阅读 · 0 评论 -
LeetCode 287. Find the Duplicate Number 题解(C++)
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the dup原创 2016-11-10 15:16:02 · 501 阅读 · 0 评论 -
LeetCode 167. Two Sum II - Input array is sorted 题解(C++)
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. - The function twoSum should return indices of the two numbers such th原创 2016-10-07 17:21:31 · 1387 阅读 · 0 评论 -
LeetCode 226. Invert Binary Tree 题解(C++)
Invert a binary tree.原创 2016-10-07 16:07:40 · 357 阅读 · 0 评论 -
LeetCode 392. Is Subsequence 题解(C++)
Given a string s and a string t, check if s is subsequence of t. - You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s原创 2016-10-19 16:06:09 · 476 阅读 · 0 评论 -
LeetCode 104. Maximum Depth of Binary Tree 题解(C++)
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.原创 2016-09-29 17:51:05 · 448 阅读 · 0 评论 -
LeetCode 412. Fizz Buzz 题解(C++)
Write a program that outputs the string representation of numbers from 1 to n.原创 2016-10-15 16:32:40 · 349 阅读 · 0 评论 -
LeetCode 144. Binary Tree Preorder Traversal 题解(C++)
Given a binary tree, return the preorder traversal of its nodes' values.原创 2016-10-25 19:55:21 · 481 阅读 · 0 评论 -
LeetCode 347. Top K Frequent Elements 题解(C++)
Given a non-empty array of integers, return the k most frequent elements.原创 2016-10-12 16:25:24 · 795 阅读 · 0 评论 -
LeetCode 100. Same Tree 题解(C++)
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.原创 2016-10-12 11:35:33 · 357 阅读 · 0 评论 -
LeetCode 384. Shuffle an Array 题解(C++)
Shuffle a set of numbers without duplicates.原创 2016-10-12 10:29:23 · 398 阅读 · 0 评论 -
LeetCode 94. Binary Tree Inorder Traversal 题解(C++)
Given a binary tree, return the inorder traversal of its nodes' values.原创 2016-10-22 15:13:42 · 525 阅读 · 0 评论 -
LeetCode 349. Intersection of Two Arrays 题解(C++)
Given two arrays, write a function to compute their intersection.原创 2016-10-11 15:44:20 · 607 阅读 · 0 评论 -
LeetCode 383. Ransom Note 题解(C++)
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from原创 2016-10-11 12:18:40 · 1073 阅读 · 0 评论 -
LeetCode 237. Delete Node in a Linked List 题解(C++)
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.原创 2016-10-11 13:17:41 · 360 阅读 · 0 评论 -
LeetCode 401. Binary Watch 题解(C++)
LeetCode 401. Binary Watch 题解(C++)题目描述A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or on原创 2016-10-21 14:48:03 · 1365 阅读 · 0 评论 -
LeetCode 415. Add Strings 题解(C++)
Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2.原创 2016-10-11 10:27:24 · 1750 阅读 · 0 评论 -
LeetCode 382. Linked List Random Node 题解(C++)
Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.原创 2016-10-10 20:24:09 · 480 阅读 · 0 评论 -
LeetCode 238. Product of Array Except Self 题解(C++)
LeetCode 238. Product of Array Except Self 题解(C++)题目描述Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums exc原创 2016-10-09 19:19:46 · 546 阅读 · 0 评论 -
LeetCode 13. Roman to Integer 题解(C++)
Given a roman numeral, convert it to an integer.原创 2016-10-23 11:00:30 · 867 阅读 · 0 评论