LeetCode刷题日常
忘词木头人
喂,起床刷题吧骚年~
展开
-
位运算#693. 交替位二进制数
位运算原创 2022-03-28 19:28:41 · 643 阅读 · 0 评论 -
LeetCode 7. 整数反转
LeetCode 7. 整数反转题目原文7. 整数反转解题思路整数反转的思路,可以通过模运算获得解题代码int reverse(int x){ int MAX = 2147483647; int MIN = -2147483648; int y = 0; while(1){ //y*10 > MAX === y > MAX/10 if(y> MAX/10 ){ return 0;原创 2022-03-23 13:16:25 · 304 阅读 · 0 评论 -
LeetCode 9. 回文数
LeetCode 9. 回文数题目原文9. 回文数解题思路回文的特点是a[i] = a[n-i]倒序后,数字依然相等 ==> 整数如何倒序 – 整数反转本题是整数的回文,采用「整数反转」后对比和原数是否相等整数反转的思路,可以通过模运算获得解题代码//1 回文的特点是a[i] = a[n-i]//2 倒序后,数字依然相等 ==> 整数如何倒序 -- 整数反转bool isPalindrome(int x){ if(x<0){原创 2022-03-23 12:43:03 · 304 阅读 · 0 评论 -
「LeetCode刷题」1. 两数之和
题目1. 两数之和https://leetcode-cn.com/problems/two-sum/题目解题思路方法1:暴力枚举/** * Note: The returned array must be malloced, assume caller calls free(). */int* twoSum(int* nums, int numsSize, int target, int* returnSize){ int *ans = (int *)malloc(sizeof(原创 2022-03-19 19:42:39 · 975 阅读 · 0 评论