061 rotate list: rotate a linkedlist: we met this kind of problems, but it just needs us to rotate an array. but for this problem, we have a genius way like make it a loop and relocate head and unleash the loop. we may say this problem is not two pointer related problem. but does...
publicclassSolution {publicintthreeSumClosest(int[] num,inttarget) {intresult = num[0] + num[1] + num[num.length - 1];//初始化Arrays.sort(num);//选择一个数for(inti = 0; i < num.length - 2; i++) {intstart = i + 1, end = num.length - 1;//双指针指向最小数和最大数wh...
windows problem: use two pointer, fix left and move right pointer, traverse source s and find the current windows containing t, then move the left point to next point to update the current window length to get the minimum window 1targetHash = {}#store the target character counter23forcint:...
题目链接https://leetcode.com/problems/intersection-of-two-linked-lists/ 题意很好懂,问题在于如何找到相交的node,想到的最简单的方法从node的最后一个节点去往前数,遇到分叉,则返回当前节点,否则返回None。这里用 两个list去保存node,从list的最后一个位置开始往前进。 代码如下,提交后,超过 99.84% 提交代码的...
leetcode合并两个有序链表python 将两个升序链表合并为一个新的升序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例: 输入:1->2->4, 1->3->4 输出:1->1->2->3->4->4 思路: 1、建立一个新链表存放排序后的节点 2、分别比较两个列表中的元素值,将小的元素节点添加到新的...
Question URL: https://leetcode.com/problems/two-sum/ Given an array of integersnumsand an integertarget, return indices of the two numbers such that they add up totarget. You may assume that each input would haveexactly one solution, and you may not use the same element twice. ...
Problem link:https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/674/Solutions: 1. Sort and merge:We firstly sort the two arrays and use two pointers to compare the ele…
LeetCode:371. Sum of Two Integers Sum of Two Integers两整数之和(C语言) 题目描述: 不使用运算符 + 和 - ,计算两整数 a 、b 之和。 示例 1: 输入: a = 1, b = 2 输出: 3 示例 2: 输入: a = -2, b...
🪟 Problems ## [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) #3 🪟 ❓: Given a string s, find the length of the longest substring without repeating characters. 🐣: 1️⃣ Input: s = "abcabcbb" Output...
LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。) - leetcode/problems/4.median-of-two-sorted-arrays.md at b58ae1e3c075ac4b831ab049a2583480d0d56cca · pearsonhan/leetcode