leetcode Add Two Numbers(对指针的一些基本操作) 1ListNode *ptr,*l;2l =newListNode(0);//这才是正确的赋值姿势3ptr = l;//赋给的是地址4intup =0,fg1 =0,fg2 =0;5//cout<<"r"<<endl;6while(1)7{8if(fg1 && fg2)break;9inta,b;10if(fg1) a =0;11elsea = l1 ->val;12if(fg2...
1//Leetcode #1: twoSum2//题目描述:给定一个数组和另外一个数target,3//若数组中某两个数的和等于target,输出这两个数的下标。4//假设只有一个解,并且同一个数不能重复使用。56#include<stdio.h>7#include<iostream>8#include<vector>910usingnamespacestd;1112classSolution {13public:14vector<int> two...
0002-add-two-numbers.rs 0003-longest-substring-without-repeating-characters.rs 0004-median-of-two-sorted-arrays.rs 0005-longest-palindromic-substring.rs 0007-reverse-integer.rs 0009-palindrome-number.rs 0011-container-with-most-water.rs 0012-integer-to-roman.rs 0013-roman-to-integer.rs 0014-longe...
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input:(2 -> 4 -> 3) + (5 -> 6 -> 4) Output:7 -> 0 -> 8 考查...
package leetcode import ( "strconv" "strings" ) func addBinary(a string, b string) string { if len(b) > len(a) { a, b = b, a } res := make([]string, len(a)+1) i, j, k, c := len(a)-1, len(b)-1, len(a), 0 for i >= 0 && j >= 0 { ai, _ := str...
0342-power-of-four Attach NOTES - LeetHub Oct 24, 2023 0347-top-k-frequent-elements Time: 12 ms (91.14%), Space: 13.7 MB (68.96%) - LeetHub May 22, 2023 0349-intersection-of-two-arrays Time: 8 ms (34.27%), Space: 12.4 MB (73.82%) - LeetHub Mar 10, 2024 0352-data-stream-...
LeetCode--single-number 题目描述: Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using e...
LeetCode——Add Binary Given two binary strings, return their sum (also a binary string). 53020 Java里面关于数组拷贝的几种方式 在java里面数组拷贝有几种方式:(1)clone (2)System.arraycopy (3)Arrays.copyOf (4)Arrays.copyOfRange 下面分别介绍下他们的用法:(...(2)如果一个类里面,又引用其他的...
921. Minimum Add to Make Parentheses Valid # 题目 # Given a string S of ‘(’ and ‘)’ parentheses, we add the minimum number of parentheses ( ‘(’ or ‘)’, and in any positions ) so that the resulting parentheses string is valid. Formally, a parent
Intersection of Two Arrays 和上边的区别是重复的元素只输出一次。 就在遍历第二个数组的时候,输出这个之后把哈希表里这个 数的值置为0就行了。 代码如下: classSolution{public:vector<int>intersection(vector<int>&nums1,vector<int>&nums2){unordered_map<int,int>m;vector<int>res;for(inti=0;i<nums1...