原题是力扣第一道题【两数之和】

我的解题代码,报错了,解决方案写在注释里了

class Solution {public:vector<int> twoSum(vector<int> &nums, int target){vector<int> vec;for (int i = 0; i < sizeof(nums)-1; i++)   //改成nums.size()就不会报错了{for (int j = i + 1; j < sizeof(nums); j++)   //改成nums.size()就不会报错了{int sum = nums[i]+nums[j];if (sum == target){vec.push_back(i);vec.push_back(j);return vec;}}}return vec;}
};

报错详情:

报错详因:
num.size()直接是直接获取当前字符串的长度,而sizeof(nums)是直接获取当前字符串所占空间的大小。

参考:https://blog.csdn.net/qq_36409711/article/details/65431318

【leetcode报错】AddressSanitizer: heap-buffer-overflow on address 0x6020000000a0 at pc 0x00000034b4d9 bp相关推荐

  1. LeetCode 报错AddressSanitizer: SEGV on unknown address 0x000000619d20 (pc 0x000000401a6a bp 0x7ffd35b3

    LeetCode90子集 II 题目描述: 给定一个可能包含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集). 说明:解集不能包含重复的子集. 示例: 输入: [1,2,2] 输出: [ ...

  2. leetcode报错:reference binding to misaligned address 0xbebebebebebec0ba for type ‘int‘, which requir 4

    leetcode,剑指offer 31题报错: Line 170: Char 16: runtime error: reference binding to misaligned address 0x ...

  3. LeetCode 报错AddressSanitizer: SEGV on unknown address (pc 0x0000003445e3 bp 0x7ffdb86b99e0 sp 0x7ffdb

    这种错误就是数组越界了. 我这里例子里即使递归结束了,没有直接return,结果计算row和col的时候就越界了.,要把return :取消注释

  4. LeetCode 报错解决 heap-buffer-overflow Heap-use-after-free Stack-buffer-overflow Global-buffer-overflow

    文章目录 前言 Heap-buffer-overflow Heap-use-after-free Stack-buffer-overflow Global-buffer-overflow 前言 在做L ...

  5. leetcode报错runtime error: reference binding to null pointer of type ‘std::vector<std::__cxx11::basic_

    leetcode报错:runtime error: reference binding to null pointer of type 'std::vector<std::__cxx11::ba ...

  6. leetcode报错:member access within null pointer of type struct ListNode

    leetcode报错:member access within null pointer of type 'struct ListNode'

  7. LeetCode报错:Line 923: Char 9: runtime error: reference binding to null pointer of type ‘std::__cxx11:

    LeetCode报错 报错原因: Line 923: Char 9: runtime error: reference binding to null pointer of type 'std::__ ...

  8. leetcode全局变量初始化问题,报错 AddressSanitizer: heap-buffer-overflow on address

    结论:leetcode中,全局变量需在函数中做初始化.因为:leetcode"提交"的代码,全局变量定义时做的初始化,可能并没有成功. 简单举例: // 报错 int a = 0; ...

  9. 力扣报错“AddressSanitizer: heap-buffer-overflow on address...”的解决办法

    做力扣报了个错: AddressSanitizer: heap-buffer-overflow on address 0x6020000001cc at pc-- 大概意思 LeetCode使用了Ad ...

最新文章

  1. python答辩结束语_2018-08-17 结束答辩
  2. Citrix运行检测出错
  3. 水晶报表Crystal 语法 实用字段编辑
  4. 查看Linus中自带的jdk ,设置JAVA_HOME
  5. openresty获取nginx请求头信息
  6. LeetCode MySQL 512. 游戏玩法分析 II
  7. 安远职业高中计算机专业,安远中等专业学校2021年招生简章
  8. JavaScript高级程序设计读书笔记(一)
  9. javascript Uncaught ReferenceError: 方法名 is not defined
  10. Vue使用Mint-ui的Popup, Picker组件报错问题
  11. coreldrawx4缩略图显示不出来_CorelDRAW缩略图不显示解决办法
  12. H5唤醒Android App
  13. Centos Ubuntu 安装 gfortran
  14. 腾讯云与智慧产业总裁汤道生:C2B是腾讯产业互联网的重要优势
  15. 利用传感器实现微信的摇一摇功能
  16. 1、STM32开发-环境搭建-Keil5安装
  17. sfc/scannow检查并修复window系统
  18. python爬虫实例大全
  19. 学计算机20天培训心得体会学生,课件制作培训心得体会(精选11篇)
  20. 20154327 Exp1 PC平台逆向破解

热门文章

  1. 干货!深度学习加速综述:算法、编译器、体系结构与硬件设计
  2. 如何使用工时表管理项目和非项目的资源?
  3. MG100-Hi3798MV100-当贝纯净桌面卡刷固件包
  4. STM32F103--485modbus通信实验
  5. 2021-11-13 - MacBook - 解决Mac外接2k显示器出现的字小和字虚的问题
  6. 电商优惠券的体验优化|含竞品分析
  7. Python学习之 a == b 和 a is b 的区别
  8. 数据结构与算法:闰年的计算方法
  9. 【SMT】SMT电子制造工艺发展趋势及PCBA电子组件可靠性现状分析
  10. 【软件工程】五、面向对象方法学 软件项目管理