OSCHINA 社区最新专区文章 |
Posted: 28 Jan 2022 03:30 AM PST 具体思路: 典型的排列组合问题,需要注意一下递归写法; 具体代码: class Solution { public: vector<string>dic = { "","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; void fun(vector<string>& ret, int index, string digits,string now) { if (index == digits.size()) { ... |
Posted: 28 Jan 2022 01:56 AM PST 基本思想: 注意特例,首尾添0最可靠; 具体代码: class Solution { public: bool canPlaceFlowers(vector<int>& flowerbed, int n) { int cnt = 0; int index = 0; flowerbed.insert(flowerbed.begin(),0); flowerbed.push_back(0); for (int i = 0; i < flowerb... |
Posted: 28 Jan 2022 01:36 AM PST 基本思路: 老生常谈的DP问题,没什么可说的,肌肉记忆; 具体代码: class Solution { public: int lengthOfLIS(vector<int>& nums) { if (nums.size() == 1) return 1; vector<int>dp(nums.size()); dp[0] = 1; for (int i = 1; i < nums.size(); i++) { ... |
You are subscribed to email updates from OSCHINA 社区最新专区文章. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google, 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
No comments:
Post a Comment