欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
  • LeetCode 155. Min Stack

    155. Min Stack解析这题不会写,(弱鸡(;´д`)ゞ)。看了discuss。C++using two stacks quite short and easy to understand。class MinStack {public: /** initialize your data...

    程序员文章站2024-01-19
  • LeetCode_155-Min Stack

    栈的实现,多加了一个最小值的获取class MinStack {public: struct Node { int nNum; int nMinNum; Node* pNext; Node() { pNext = n...

    程序员文章站2024-01-19
  • Leetcode-Easy 155. Min Stack

    234. Palindrome Linked List描述:栈的实现思路:通过列表进行实现代码class MinStack: def __init__(self): """ initialize your data structure here. ""...

    程序员文章站2024-01-19
  • [LeetCode]155. Min Stack

    [LeetCode]155. Min Stack题目描述思路两个vector 一个vector存储栈 另一个vector存储到目前为止最小值的下标代码#include <iostream>#include <vector>#include <algorithm>u...

    程序员文章站2024-01-19
  • 【LeetCode】第一题:两数之和

    题目给定一个整数数组nums和一个目标值target,请你在该数组中找出和为目标值的那两个整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。示例:给定 nums = [2, 7, 11, 15], target = 9因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1]...

    程序员文章站2024-01-19
  • LeetCode LCP09:最小跳跃次数——广度优先搜索的优雅写法

    前言看评论又学了一手:以往在广度优先搜索的场景中,使用一个队列,如果想进行层次的遍历,我的做法是再new一个队列,把新出现的元素放到新队列中,完成后再将新队列赋给原先的指针。即while(!queue.isEmpty()) {Queue next = new LinkedList();int cur = queue.poll();while(!queue.isEmpty()) {//add some item to new queue}//fin

    程序员文章站2024-01-18
  • LeetCode 160 - Intersection of Two Linked Lists

    Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists:A: ...

    程序员文章站2024-01-18
  • leetcode 17 电话号码的数字组合

    给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 1 class Solution { 2 List temp=new ArrayList(); 3 Map

    程序员文章站2024-01-18
  • LeetCode 46 - Permutations

    Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1]...

    程序员文章站2024-01-18
  • Leetcode 454. 4Sum II

    Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make prob...

    程序员文章站2024-01-17
  • [题记]链表的中间节点-leetcode

    题目:链表的中间节点、 给定一个带有头结点 head 的非空单链表,返回链表的中间结点。 如果有两个中间结点,则返回第二个中间结点。 示例 1: 输入:[1,2,3,4,5]输出:此列表中的结点 3 (序列化形式:[3,4,5])返回的结点值为 3 。 (测评系统对该结点序列化表述是 [3,4,5] ...

    程序员文章站2024-01-17
  • LeetCode 193. Valid Phone Numbers

    分析 难度 易 来源 https://leetcode.com/problems/valid-phone-numbers/ 题目 Given a text file file.txt that contains list of phone numbers (one per line), write ...

    程序员文章站2024-01-16
  • LeetCode-297.Serialize and Deserialize Binary Tree(二叉树的序列化和反序列化)

    LeetCode-297.Serialize and Deserialize Binary Tree(二叉树的序列化和反序列化)题意及解题思路层序序列化和层序反序列化完整测试代码题目链接题意当然上面这个是按层序列化,我们也可以按前序序列化,只要能通过序列化的结果还原二叉树即可。解析前序序列化,就是将...

    程序员文章站2024-01-15
  • Leetcode---栈系列刷题(python3实现)----#20有效的括号

    我最近在学习python3,基础不是很好,所以准备在Leetcode上刷题,这个作为笔记记录我的,如果大家看到有错误,拜托大家帮我指出,谢谢啦~ ...

    程序员文章站2024-01-14
  • Leetcode题Binary Search: 222/230/240/275/278/300,Python多种解法(十五)

    文章目录前文222. Count Complete Tree Nodes230. Kth Smallest Element in a BST240. Search a 2D Matrix II275. H-Index II278. First Bad Version300. Longest Incr...

    程序员文章站2024-01-14
  • LeetCode BinarySearch 702 Search in a Sorted Array of Unknown Size

    702. Search in a Sorted Array of Unknown SizeGiven an integer array sorted in ascending order, write a function to search target in nums. If target ex...

    程序员文章站2024-01-13
  • LeetCode BinarySearch 278 first bad version

    Leetcode 278 first bad versionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of yo...

    程序员文章站2024-01-13
  • LeetCode_35. Search Insert Position

    ***About vector, we can refer to the link below:https://www.runoob.com/w3cnote/cpp-vector-container-analysis.htmlhttps://blog.csdn.net/AFishhhhhh/arti...

    程序员文章站2024-01-13
  • 【LeetCode】 15. 三数之和 思路详解

    题目题目传送门:传送门(点击此处跳转)题解思路本身这道题也没啥思路,所以还是败给了看题解才找到答案首先想到的肯定是遍历,暴力法可以实现,大不了,就是 n3 的时间复杂度嘛,不过这样肯定不合适,所以要继续优化先排序,然后遍历绝对是少不了的,所以这一步肯定跳不过去。我们一共需要三个数,第一个数通过遍历获...

    程序员文章站2024-01-11
  • LeetCode 力扣 101. 对称二叉树

    题目描述(简单难度)判断一个二叉树是否关于中心轴对称。解法一和 100 题 判断两个二叉树是否相等其实是一样的思路,都是用某种遍历方法来同时遍历两个树,然后看是否对应相等。这里的需要遍历的两个树就是左子树和右子树了。这里的对应相等的话,因为判断左子树 A 和右子树 B 是否对称,需要判断两点。A 的...

    程序员文章站2024-01-11