![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法分析与设计作业 leetcode
狗急跳门
这个作者很懒,什么都没留下…
展开
-
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 阅读 · 0 评论 -
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 · 145 阅读 · 0 评论 -
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 · 167 阅读 · 0 评论 -
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 · 166 阅读 · 0 评论 -
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 · 126 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 171 阅读 · 0 评论 -
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 · 105 阅读 · 0 评论 -
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 · 137 阅读 · 0 评论 -
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 · 180 阅读 · 0 评论 -
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 · 122 阅读 · 0 评论 -
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 · 226 阅读 · 0 评论 -
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 · 146 阅读 · 0 评论 -
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 · 140 阅读 · 0 评论 -
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 · 178 阅读 · 0 评论 -
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 · 139 阅读 · 0 评论 -
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 · 488 阅读 · 0 评论 -
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 · 144 阅读 · 0 评论