- 博客(19)
- 收藏
- 关注
原创 LeetCode 121. Best Time to Buy and Sell Stock
题目 Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the sto
2018-01-20 15:50:41
146
原创 LeetCode 169. Majority Element
题目 Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority elemen
2018-01-20 15:16:09
158
原创 LeetCode 55. Jump Game
题目 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 maximum jump length at that position. Deter
2018-01-02 23:23:02
182
原创 LeetCode 605. Can Place Flowers
题目 Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.
2018-01-02 21:50:23
168
原创 算法概论 练习8.3
题目STINGY SAT 指的是:给定一组子句(每个子句都是文字的析取)和整数k,如果存在,求一个最多有 k 个变量为 true 的满足赋值。证明 STINGY SAT 是 NP 完全问题。证明
2017-12-30 15:16:39
164
原创 LeetCode 396. Rotate Function
题目 Given an array of integers A and let n to be its length. Assume BkB_k to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function” F on A as follow:
2017-12-07 15:57:22
128
原创 LeetCode 540. Single Element in a Sorted Array
题目 Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element that appears only once. Example: Input: [1
2017-12-06 19:18:04
143
原创 LeetCode 537. Complex Number Multiplication
题目 Given two strings representing two complex numbers. You need to return a string representing their multiplication. Note i2 = -1 according to the definition. Example: Input: “1+1i”, “1+1i”
2017-11-19 20:18:50
177
原创 LeetCode 202. Happy Number
题目 Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squ
2017-11-19 19:44:01
106
原创 LeetCode 415. Add Strings
题目 Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note: 1. The length of both num1 and num2 is < 5100. 2. Both num1 and num2 contains only dig
2017-10-29 14:51:18
240
原创 LeetCode 434. Number of Segments in a String
题目 Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. Please note that the string does not contain any non-printable characte
2017-10-15 14:42:48
139
原创 LeetCode 35. Search Insert Position
题目 Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the ar
2017-10-15 14:36:28
181
原创 LeetCode 102. Binary Tree Level Order Traversal
题目 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,null,null,15,7], 3 / \ 9 20
2017-10-15 14:28:34
126
原创 LeetCode 27. Remove Element
题目 Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory
2017-09-20 19:43:04
147
原创 LeetCode 7. Reverse Integer
题目 Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321 Have you thought about this? Here are some good questions to ask before coding. Bonus points for
2017-09-20 19:35:47
141
原创 LeetCode 561. Array Partition I
题目 Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as po
2017-09-20 19:06:48
181
原创 LeetCode 70. Climbing Stairs
题目 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a
2017-09-20 18:46:47
140
原创 LeetCode 106. 已知中序和后序遍历构建二叉树
LeetCode 106. 已知中序和后序遍历构建二叉树题目 Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.
2017-09-13 19:02:20
490
原创 LeetCode 292. Nim Game
LeetCode 292. Nim Game一个数学问题。题目 You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who r
2017-09-11 18:50:05
205
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人