数据结构与算法
安宣
希望每天叫醒你的不是闹钟而是梦想 ————XCWBKZJ
展开
-
数据结构与算法之leetcode递归和分治
剑指 Offer 10- I. 斐波那契数列 public class Solution { public int Fib(int n) { int a = 0; int b = 1; int sum = 0; for (int i = 0; i < n; i++) { sum = (a + b) % 1000000007; a = b;原创 2021-06-29 16:24:32 · 101 阅读 · 0 评论 -
数据结构与算法之leetcod栈和队列
剑指 Offer 09. 用两个栈实现队列 public class CQueue { //两个栈实现队列 Stack<int> stack1; Stack<int> stack2; public CQueue() { stack1 = new Stack<int>(); stack2 = new Stack<int>(); } public void AppendTai原创 2021-06-22 16:41:46 · 153 阅读 · 0 评论 -
数据结构与算法之leetcode数组和链表
203. 移除链表元素 /** * Definition for singly-linked list. * public class ListNode { * public int val; * public ListNode next; * public ListNode(int val=0, ListNode next=null) { * this.val = val; * this.next = next; * } *原创 2021-06-21 10:17:51 · 105 阅读 · 0 评论 -
数据结构与算法之leetcode找规律题
面试题 01.08. 零矩阵 public class Solution { public void SetZeroes(int[][] matrix) { // 1 0 1 // 1 1 0 // 2 2 2 //创建 变量记录第一行 第一列是否有0存在 bool firstRow = false; bool firstCol = false; int row = matrix.Length;原创 2021-06-04 12:05:08 · 105 阅读 · 0 评论 -
数据结构与算法之leetcode纯编程题
1.两数之和 public class Solution { public int[] TwoSum(int[] nums, int target) { Dictionary<int,int> dic = new Dictionary<int,int>(); for(int i = 0;i<nums.Length;i++){ if(dic.ContainsKey(nums[i])){原创 2021-06-02 16:42:52 · 128 阅读 · 0 评论