[LeetCode]--3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. leetcode all in one,Examples: Given “abcabcbb”, the answer is “abc”, which the length is 3. Given “bbbbb”, the answer is “b”, with the length of 1. Given “pw
时间:2023-09-13  |  阅读:27
LeetCode:Rotate Image
You are given annxn2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? 不使用额外的空间顺时针旋转方阵90度 例如 旋转后变为 算法1 先将矩阵转置,然后把转置后的矩阵每一行翻转 转置变为 每
时间:2023-09-13  |  阅读:27
leetcode讲解--693. Binary Number with Alternating Bits
题目 Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. Example 1: Input: 5 Output: True Explanation: The binary representation of 5 is: 101 Example 2: Input: 7 Output: False E
时间:2023-09-13  |  阅读:23
[LeetCode]Remove Nth Node From End of List
又一道链表题。CareerCup上也有类似题目,trick和“部分链表逆序”一样,由于不知道链表的长度,second指针比first指针先走n步,然后在同时向前移动,直到second指针到达链表尾。注意删除头节点的情况。 假设链表长度为N,倒数第k个节点
时间:2023-09-11  |  阅读:25
[LeetCode]Power
周五的晚上,女朋友看爸爸去哪儿,电脑都是我的,狂刷LeetCode,做了十来题,最有印象的还是Power。题目如下: Implement pow(x,n).就是实现x的n次方。 leetCode,这是一题很传统的题目了,但是之前没认真思考过。 第一个想法&#x
时间:2023-09-11  |  阅读:23
LeetCode | 3 Sum
Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c) must be in non-descending order. (ie,a≤b≤c)The solution set must
时间:2023-09-11  |  阅读:25
leetcode_Basic Calculator II
题目: Implement a basic calculator to evaluate a simple expression string. The expression string contains onlynon-negativeintegers,+,-,*,/operators and empty spaces. The integer division should truncate toward zero. You may assume that the giv
时间:2023-09-11  |  阅读:25
leetcode:Majority Number
1、Given an array of integers, the majority number is the number that occursmore than halfof the size of the array. Find it. Given[1, 1, 1, 1, 2, 2, 2], return1 2、得到当前数组中个数最多的一个数 3、代码    public class MajorityNumber {public static int
时间:2023-09-11  |  阅读:27
[Leetcode]141. Linked List Cycle
题目: Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? leetCode。让head不断走一步,如果cur不为null,走两步,这样如果存在cycle,cur会追上head。 /*** Definition for
时间:2023-09-11  |  阅读:23
[LeetCode] 513. Find Bottom Left Tree Value_ Medium tag: BFS
Given a binary tree, find the leftmost value in the last row of the tree. leetcode1120、Example 1: Input:2/ \1 3Output: 1 Example 2: Input:1/ \2 3/ / \4 5 6/7Output: 7 Note:You may assume the tree (i.e., the given root node) is notNULL. 这个题的思路其实
时间:2023-09-11  |  阅读:24

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息