摘要: class Solution { public: //f[i]表示跳到i所需的最小步数 int jump(vector<int>& nums) { vector<int> f(10010,0x3f3f3f3f); int n=nums.size(); f[0]=0; for(int i=0;i<n; 阅读全文
posted @ 2023-03-24 14:26 穿过雾的阴霾 阅读(20) 评论(0) 推荐(0)
摘要: class Solution { public: //f[i]表示下标i是否能跳到 static const int N=3e4+10; bool canJump(vector<int>& nums) { int n=nums.size(); for(int i=0,j=0;i<n;i++)//j记 阅读全文
posted @ 2023-03-24 14:15 穿过雾的阴霾 阅读(15) 评论(0) 推荐(0)
摘要: #方法1,遍历一次,使用额外空间 哈希直接存储指针出现的次数,如果重复出现,直接返回即可 class Solution { public: unordered_map<ListNode*,int> hashmap;//记录指针及其出现的次数+1 ListNode *entryNodeOfLoop(L 阅读全文
posted @ 2023-03-24 11:50 穿过雾的阴霾 阅读(13) 评论(0) 推荐(0)