LeetCode(43)-Contains Duplicate II
题目:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and t...
LeetCode Day3
Lowest Common Ancestor of a Binary Search Tree import java.util.ArrayList; import java.util.List; /** * LeetCode: Lowest Common Ancestor of a Binary...
LeetCode 题目 94:五种算法递归|迭代|莫里斯|线索二叉树|栈的迭代二叉树 实现中序遍历
作者介绍:10年大厂数据\经营分析经验,现任大厂数据部门负责人。 会一些的技术:数据分析、算法、SQL、大数据相关、python 欢迎加入社区:码上找工作 作者专栏每日更新:LeetCode解锁1000题: 打怪升级之旅python数据分析可视化:企业实战案例python源码解读程序员必备的数学...
✡ leetcode 168. Excel Sheet Column Title 26进制数字 --------- java
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ......
【算法刷题day45】卡码网:70. 爬楼梯(进阶版);Leetcode:322. 零钱兑换、279. 完全平方数
文章目录 Leetcode 70. 爬楼梯(进阶版)解题思路代码总结Leetcode 322. 零钱兑换解题思路代码总结Leetcode 279. 完全平方数解题思路代码总结 草稿图网站java的Deque Leetcode 70. 爬楼梯(进阶版) 题目:70. 爬楼梯(进阶版)解析...
【算法刷题day43】Leetcode:1049. 最后一块石头的重量 II、494. 目标和、474. 一和零-Leetcode 494. 目标和
题目:494. 目标和解析:代码随想录解析 解题思路 例如:dp[j],j 为5, 已经有一个1(nums[i]) 的话,有 dp[4]种方法 凑成 容量为5的背包。 已经有一个2(nums[i]) 的话,有 dp[3]种方法 凑成 容量为5的背包。 已经有一个3(nums[i]) 的话,有...
[LeetCode] Advantage Shuffle 优势洗牌
Given two arrays `A` and `B` of equal size, the *advantage of `A` with respect to `B`* is the number of indices `i` for which `A[i] > B[i]`.Return ...
【LeetCode刷题】739. 每日温度(单调栈)-4. 代码
class Solution {public: vector<int> dailyTemperatures(vector<int>& temperatures) { stack<int> st; int n = ...
leetcode@ [54/59] Spiral Matrix & Spiral Matrix II
https://leetcode.com/problems/spiral-matrix/Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Fo...
Java | Leetcode Java题解之第69题x的平方根-题解:
class Solution { public int mySqrt(int x) { if (x == 0) { return 0; } double C = x, x0 = x; while (true) {
[LeetCode]题解(python):066-Plus One
题目来源:https://leetcode.com/problems/plus-one/题意分析:给定一个数组,将数加一,返回新的数组。比如[9,9],返回[1,0,0]。题目思路:这道题目很简单,尾数加1,然后如果进位就向前一个数字加1.代码(Python): class Solution(obj...
Leetcode—1396. 设计地铁系统【中等】
class UndergroundSystem {public: typedef struct Checkin { string startStation; int time; } Checkin; typedef struct Checkout{ ...
LEETCODE 150. 逆波兰表达式求值
class Solution: def evalRPN(self, tokens: List[str]) -> int: # if not tokens: # return -1 # if len(tokens)==1 and toke...
Golang | Leetcode Golang题解之第61题旋转链表-题解:
func rotateRight(head *ListNode, k int) *ListNode { if k == 0 || head == nil || head.Next == nil { return head } n := 1 iter := he
LeetCode1005:K次取反后最大化的数组和
题目描述 给你一个整数数组 nums 和一个整数 k ,按以下方法修改该数组: 选择某个下标 i 并将 nums[i] 替换为 -nums[i] 。 重复这个过程恰好 k 次。可以多次选择同一个下标 i 。 以这种方式修改数组后,返回数组 可能的最大和 。 解题思想 第一步:将数组按照绝对值大小从大...
LeetCode OJ--Swap Nodes in Pairs
https://oj.leetcode.com/problems/swap-nodes-in-pairs/链表的处理/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *...
leetCode 题解之字符串中第一个不重复出现的字符
1、题目描述Given a string, find the first non-repeating character in it and return it's index.If it doesn't exist, return -1.Examples: s = "leetcode" retu...
【Leetcode每日一题】 综合练习 - 全排列 II(难度⭐⭐)(71)
1. 题目解析 题目链接:47. 全排列 II 这个问题的理解其实相当简单,只需看一下示例,基本就能明白其含义了。 2.算法原理 算法思路梳理 为了生成给定数组nums的全排列,同时避免由于重复元素导致的重复排列,我们可以遵循以下步骤和策略: 预处理与排序 由于题目不要求返回排列的顺序,我们可...
简单的洗牌算法Java加LeetCode刷题
CardDemo类创建 import java.util.ArrayList;import java.util.List;import java.util.Random;import java.util.concurrent.CopyOnWriteArrayList;public class Car...
LeetCode_Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ...