Leetcode刷题
这里会记录我刷Leetcode的一些代码和刷题新的
YaruCode
这个作者很懒,什么都没留下…
展开
-
LeetCode 83题目 删除排序链表中的重复元素
【代码】LeetCode 83题目 删除排序链表中的重复元素。原创 2023-07-15 09:51:29 · 44 阅读 · 0 评论 -
Leetcode 19题 删除链表的倒数第 N 个结点
【代码】Leetcode 19题 删除链表的倒数第 N 个结点。原创 2023-07-15 09:04:53 · 42 阅读 · 0 评论 -
LeetCode21 合并有序链表
【代码】LeetCode21 合并有序链表。原创 2023-07-15 08:35:18 · 44 阅读 · 0 评论 -
Leetcode最后一个单词的长度
Leetcode最后一个单词的长度 public class Solution { public int LengthOfLastWord(string s) { s=s.Trim(); string[] strs=s.Split(' '); return strs[strs.Length-1].Length; } }原创 2022-03-22 21:27:47 · 120 阅读 · 0 评论 -
Leetcode回文数字
Leetcode7题 回文数字 public class Solution { public bool IsPalindrome(int x) { if(x<0) { return false; } List<int> list=new List<int>(); while(x!=0) { list.Add(x%10);原创 2022-03-22 21:21:34 · 154 阅读 · 0 评论 -
Leetcode第一题两数之和
用暴力解决两束之和 public class Solution { public int[] TwoSum(int[] nums, int target) { int[] ans=new int[2]; for(int i=0;i<nums.Length;i++) { for(int j=i+1;j<nums.Length;j++) { if(nums[i]+nu原创 2022-03-22 21:15:06 · 153 阅读 · 0 评论 -
leetcode739题每日温度
leetcode739题每日温度 题目: 给定一个整数数组 temperatures ,表示每天的温度,返回一个数组 answer ,其中 answer[i] 是指在第 i 天之后,才会有更高的温度。如果气温在这之后都不会升高,请在该位置用 0 来代替。 class Solution { public int[] dailyTemperatures(int[] temperatures) { /** 题意解释: */原创 2022-02-26 16:07:03 · 705 阅读 · 0 评论 -
leetcode145题二叉树的后序遍历
leetcode145题二叉树的后序遍历 题目: 给你一棵二叉树的根节点 root ,返回其节点值的 后序遍历 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } *原创 2022-02-26 14:49:38 · 188 阅读 · 0 评论 -
leetcode144题二叉树的中序遍历
leetcode144题二叉树的中序遍历 题目: 给你二叉树的根节点 root ,返回它节点值的 前序 遍历。 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } *原创 2022-02-26 14:47:52 · 134 阅读 · 0 评论