- 博客(255)
- 资源 (24)
- 收藏
- 关注
原创 【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
183
原创 【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
460
原创 【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
337
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
208
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
277
原创 【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
627
原创 【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
323
原创 【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
222
原创 【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
399
原创 【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
184
原创 【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
593
原创 【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
213
原创 【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
165
原创 【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
417
原创 【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
183
原创 【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
555
原创 【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
733
原创 【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
248
原创 【Daily Pratice】【数组】之子数组问题--题解(4-6)
【代码】【Daily Pratice】【数组】之子数组问题--题解(4-5)
2024-03-18 23:20:12
791
原创 【Daily Pratice】【数组】之子数组问题--题解(1-3)
Split an array into two equal Sum subarrays(脸书面试题)
2024-03-17 21:35:36
403
原创 【JSD1209考试】题目与解答
编写一个TCP服务程序,在5000号端口监听提供“字符反转”服务,即接收到客户端的一行数据后,将该行数据反转(例如123456变成654321)返回给客户端,如果收到“EndLine”,就结束与客户端的连接,如果客户端主动断开连接也同样处理。用SWING包编写一段代码重复地在屏幕上的随机位置用随机颜色画随机尺寸的圆形和矩形(形状也是随机出现),并在图形中间写一段文字(20分)(4)写SQL语句得到如下查询结果(所有人的成绩和年龄,即使这个人没有成绩也要显示成绩栏为空):(4分)数列1,1,2,3,5,…
2023-12-05 23:08:47
90
原创 【LeetCode 0001】【数组】两数之和
Given an array of integers and an integer , return indices of the two numbers such that they add up to .You may assume that each input would have exactly one solution, and you may not use the same element twice.You can return the answer in any order.Examp
2023-11-29 23:45:51
372
逆波兰式表达式计算引擎
2014-11-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人