- 博客(265)
- 资源 (24)
- 收藏
- 关注
原创 【LeetCode 0006】【字符/几何】Z字形变换
The string is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)And then read line by line: Write the code that will take a string and make this conversion given a
2024-07-29 10:00:00 145
原创 【LeetCode 0005】【动态规划】最长回文子串
Given a string , return the longest palindromic substring in .Example 1:Example 2:Constraints:
2024-07-28 22:43:01 180
原创 【LeetCode 0004】【数组/分治】寻找两个正序数组的中位数
Given two sorted arrays and of size and respectively, return the median of the two sorted arrays.The overall run time complexity should be .Example 1:Example 2:Constraints:
2024-07-25 08:00:00 178
原创 【LeetCode 0003】【滑动窗口】无重复字符的最长子串
Given a string `s`, find the length of the **longest** **substring** without repeating characters.
2024-07-24 23:34:45 417 1
原创 【LeetCode 0002】【链表】两数相加
You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
2024-07-24 23:31:12 355
原创 【LeetCode 0037】【回溯/剪枝】解数独
Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:The character indicates empty cells.Example 1:Constraints:
2024-07-22 00:03:16 311
原创 【LeetCode 0338】【位运算/递归式】求比特位
Given an integer , return *an array of length such that for each (), is the number of ’s in the binary representation of *.Example 1:Example 2:Constraints:Follow up:
2024-07-21 08:00:00 649 1
原创 【LeetCode 0231】【位运算】2的N次方
Given an integer , return if it is a power of two. Otherwise, return .An integer is a power of two, if there exists an integer such that .Example 1:Example 2:Example 3:Constraints:Follow up: Could you solve it without loops/recursion?
2024-07-20 23:38:28 368 1
原创 【LeetCode 0191】【位运算】求1的个数
Write a function that takes the binary representation of a positive integer and returns the number of set bits it has (also known as the Hamming weight).Example 1:Output: 3Explanation:The input binary string 1011 has a total of three set bits.Example 2:Out
2024-07-19 09:34:10 377
原创 【LeetCode 0069】【二分查找】求平方根
Given a non-negative integer , return the square root of rounded down to the nearest integer. The returned integer should be non-negative as well.You must not use any built-in exponent function or operator.Example 1:Example 2:Constraints:
2024-07-17 23:43:01 314
原创 【LeetCode 0051】【剪枝】N皇后
The n-queens puzzle is the problem of placing queens on an chessboard such that no two queens attack each other.Given an integer , return all distinct solutions to the n-queens puzzle. You may return the answer in any order.Each solution contains a disti
2024-07-15 23:53:32 681
原创 【LeetCode 0022】【DSF】生成括号
Given `n` pairs of parentheses, write a function to *generate all combinations of well-formed parentheses*.
2024-07-14 18:22:22 160
原创 【LeetCode 0104】【递归/分治】二叉树的最大深度
Given the of a binary tree, return its maximum depth.A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Example 1:Example 2:Constraints:
2024-07-13 14:16:52 367 2
原创 【LeetCode 0102】【BSF/DSF】二叉树的层级遍历
Given the of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level).Example 1:Example 2:Example 3:Constraints:
2024-07-12 23:47:56 239 1
原创 【LeetCode 0122】【DSF/DP/Greedy】买卖股票的最佳时机2
You are given an integer array where is the price of a given stock on the day.On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then immediately sell it on the
2024-07-11 23:06:54 301
原创 【LeetCode 0169】【摩尔投票算法】主元素
Given an array of size , return the majority element.The majority element is the element that appears more than times. You may assume that the majority element always exists in the array.Example 1:Example 2:Constraints:Follow-up: Could you solve the pr
2024-07-11 22:44:33 649
原创 【LeetCode 0050】【分治/递归】求x的n次方
Implement pow(x, n), which calculates raised to the power (i.e., ).Example 1:Example 2:Example 3:Constraints:
2024-07-09 23:58:16 337
原创 【LeetCode 0088】 【数组/双指针】合并两个有序数组
You are given two integer arrays and , sorted in non-decreasing order, and two integers and , representing the number of elements in and respectively.Merge and into a single array sorted in non-decreasing order.The final sorted array should not be re
2024-07-09 23:43:09 236
原创 【LeetCode 0098】【BST】验证有效的二叉查找树
Given the of a binary tree, determine if it is a valid binary search tree (BST).A valid BST is defined as follows:Example 1:Example 2:Constraints:
2024-07-08 09:30:00 412
原创 【LeetCode 0239】【大堆/双端队列】滑动窗口中的最大值
You are given an array of integers , there is a sliding window of size which is moving from the very left of the array to the very right. You can only see the numbers in the window. Each time the sliding window moves right by one position.Return the max
2024-07-07 18:10:24 195
原创 【LeetCode 0141】【链表】【双指针之快慢指针】判断给定单链表是否存在环
Given , the head of a linked list, determine if the linked list has a cycle in it.There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the pointer. Internally, is used to denote the index
2024-07-07 13:51:29 599
原创 【LeetCode 0206】【链表】反转单链表
Given the of a singly linked list, reverse the list, and return the reversed list.Example 1:Example 2:Example 3:Constraints:Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?
2024-07-06 17:24:12 220
原创 【LeetCode 0242】【Map/排序】有效的异位词
Given two strings and , return if is an anagram of , and otherwise.An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.Example 1:Example 2:Constraints:F
2024-07-05 23:23:19 174
原创 【LeetCode 0146】【设计】【双向循环链表】实现LRU缓存
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.Implement the class:The functions and must each run in average time complexity.Example 1:Constraints:
2024-07-04 20:31:48 424
原创 【LeetCode 0703】【设计】【优先队列】返回数据流中第K大的元素
Design a class to find the largest element in a stream. Note that it is the largest element in the sorted order, not the distinct element.Implement class:Example 1:Constraints:
2024-07-03 23:56:38 201
原创 【LeetCode 0232】【设计】用FILO栈实现FIFO队列
Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (, , , and ).Implement the class:* Pushes element x to the back of the queue.* Removes the element from the front
2024-07-03 20:53:59 565
原创 【LeetCode 0225】【设计】用FIFO队列实现FILO栈
Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (, , , and ).Implement the class:Notes:Example 1:Constraints:Follow-up: Can you implement the stack using only one
2024-07-02 23:22:20 745
原创 【LeetCode 0020】【栈】有效的括号
Given a string containing just the characters , , , , and , determine if the input string is valid.An input string is valid if:Example 1:Example 2:Example 3:Constraints:* * consists of parentheses only .
2024-07-01 23:59:53 253
原创 【Daily Pratice】【数组】之子数组问题--题解(4-6)
【代码】【Daily Pratice】【数组】之子数组问题--题解(4-5)
2024-03-18 23:20:12 794
逆波兰式表达式计算引擎
2014-11-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人