LeetCode
仙女阳
希望多学习
展开
-
LeetCode-best time to buy and sell stock 2 数组
1、问题: Say you have an array for which theithelement is the price of a given stock on dayi. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, ...原创 2019-04-10 11:03:07 · 147 阅读 · 0 评论 -
LeetCode-best time to buy and sell stock 1 数组
1.问题 Say you have an array for which theithelement is the price of a given stock on dayi. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the st...原创 2019-04-10 21:00:41 · 155 阅读 · 0 评论 -
LeetCode--single-number复杂度
1、题目 给定一个整数数组,每个元素都出现了两次,但有一个只出现了一次,请找出这个数。 Note:算法要求有线性时间复杂度,并且不占用额外的空间。 2、解法: public class Solution { public int singleNumber(int[] A) { int re=0; int i; for(i= 0;i&...原创 2019-04-09 21:35:20 · 204 阅读 · 0 评论 -
LeetCode-reverse integer复杂度
1、题目: Reverse digits of an integer. Example1:x = 123, return 321Example2:x = -123, return -321 Have you thought about this? Here are some good questions to ask before coding. Bonus points for yo...原创 2019-04-09 21:51:21 · 290 阅读 · 0 评论 -
LeetCode--palindrome-number回文数
1、问题 Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of convert...原创 2019-05-30 19:50:34 · 155 阅读 · 0 评论