
leetcode
小小小白坤
转行路漫漫,再坚持一下吧
展开
-
天天刷leetcode(6) ---- 451.Sort Characters By Frequency
问题描述Given a string, sort it in decreasing order based on the frequency of characters.给定一个字符串,请将字符串里的字符按照出现的频率降序排列。思路使用hashtable遍历字符串,将出现频率记录在hashtable中,最后利用hashtable对原字符串进行排序class Solution {public: string frequencySort(string s) {原创 2020-09-30 11:11:34 · 159 阅读 · 0 评论 -
天天刷leetcode(5) ---- 146. LRU Cache
问题描述Design a data structure that follows the constraints of a LeastRecently Used (LRU) cache.Implement the LRUCache class:LRUCache(int capacity) Initialize the LRU cache with positive size capacity.int get(int key) Return the value of the key if原创 2020-09-29 14:14:02 · 206 阅读 · 0 评论 -
天天刷leetcode(4) ---- 676. Implement Magic Dictionary
问题描述Design a data structure that is initialized with a list of differentwords. Provided a string, you should determine if you can changeexactly one character in this string to match any word in the datastructure. Implement the MagicDictionary class:原创 2020-09-28 15:04:45 · 182 阅读 · 0 评论 -
天天刷leetcode(3) ---- 139.Word Break
问题描述Given a non-empty string s and a dictionary wordDict containing a listof non-empty words, determine if s can be segmented into aspace-separated sequence of one or more dictionary words.Note:The same word in the dictionary may be reused multiple原创 2020-09-27 16:29:40 · 136 阅读 · 0 评论 -
天天刷leetcode(2) ---- 141.Linked List Cycle
问题描述Given head, the head of a linked list, determine if the linked list has a cycle in it.There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used t原创 2020-09-26 14:39:31 · 150 阅读 · 0 评论 -
天天刷leetcode(1) ---- Two Sum
问题描述Given an array of integers nums and an integer target, return indicesof the two numbers such that they add up to target.You may assume that each input would have exactly one solution, andyou may not use the same element twice.You can return the a原创 2020-09-25 11:36:24 · 233 阅读 · 0 评论 -
LeetCode 第一题 (Python)
题目内容Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the sam原创 2018-04-22 01:49:40 · 4172 阅读 · 0 评论 -
LeetCode 买卖股票的最佳时间系列习题 python(上)
121.买卖股票的最佳时间 I题目内容给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。 注意你不能在买入股票前卖出股票。思路引入两个变量,最小买入价格和最大利润,遍历数组,判断最大和最小值来得到最后的结果。代码class Solution: def maxProfit(self原创 2018-05-04 01:28:45 · 4310 阅读 · 1 评论