![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
Hey_Chen
这个作者很懒,什么都没留下…
展开
-
【leetcode-2.16】memset和puts的用法 for循环的简便写法
void * memset ( void * ptr, int value, size_t num );Fill block of memorySets the firstnumbytes of the block of memory pointed byptrto the specifiedvalue(interpreted as anunsigned char).in...原创 2020-02-16 13:57:30 · 337 阅读 · 0 评论 -
符号:>>=表示二进制右移再赋值
for ( ; i ^ 1; i >>= 1){}for循环,判断条件为i^1(即i的二进制最低位与1进行位异或),i>>=1将i的二进制值右移1为再赋给i原创 2020-02-16 13:07:51 · 348 阅读 · 0 评论 -
【LeetCode 1269】用一个循环代替判断优化代码
具体情况之前: for(int i=2;i<=steps;i++){ for(int j=0;j<arrLen;j++){ f[i][j]=f[i-1][j]; if(j!=0) f[i][j]+=f[i-1][j-1]; ...原创 2020-02-13 11:23:33 · 141 阅读 · 0 评论 -
【LeetCode 1269】用按位与判断奇偶
https://blog.csdn.net/machi1/article/details/87884731举例:4&1:100&001=05&1:101&001=1原创 2020-02-13 11:14:35 · 215 阅读 · 0 评论 -
<leetcode>#2 Add Two Numbers
My Solution:主要思路就是同时读入两个list,并相加,记录是否需要进位取余的情况,当一个list到最后时,直接读另一个list,同时也要考虑进位情况。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ...原创 2019-03-02 16:16:27 · 219 阅读 · 0 评论 -
<leetcode>#1 Tow Sum
My solution:class Solution { public int[] twoSum(int[] nums, int target) { int[] result = new int[2]; for(int i=0;i<nums.length-1;i++){ for(int j=i+1;j<nums.le...翻译 2019-02-26 21:50:23 · 102 阅读 · 0 评论 -
<leetcode>#3 Longest Substring Without Repeating Characters
My Solution:主要思路:now指针不断后移,每移动一个就与前面的字母比较是否有相同,若有相同,比较当前substring长度是否大于max,记此时相同的位置后一个位置为front,now继续后移...class Solution { public int lengthOfLongestSubstring(String s) { int front = 0...原创 2019-03-03 21:19:14 · 120 阅读 · 0 评论 -
<leetcode>#7 Reverse Integer
My Solution:class Solution { public int reverse(int x) { int result = 0; int sign = 1; if(x<0) { sign = -1; x = -x; } while(x&...原创 2019-03-03 21:57:50 · 94 阅读 · 0 评论