diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json deleted file mode 100644 index 6b611411..00000000 --- a/.vs/VSWorkspaceState.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "ExpandedNodes": [ - "" - ], - "PreviewInSolutionExplorer": false -} \ No newline at end of file diff --git a/.vs/algorithmA/v16/.suo b/.vs/algorithmA/v16/.suo deleted file mode 100644 index 1c84771b..00000000 Binary files a/.vs/algorithmA/v16/.suo and /dev/null differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 2b242466..e748e204 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/Week_01/id_59/LeedCode_189.cs b/Week_01/id_59/LeedCode_189_59.C# similarity index 100% rename from Week_01/id_59/LeedCode_189.cs rename to Week_01/id_59/LeedCode_189_59.C# diff --git a/Week_01/id_59/LeedCode_26.cs b/Week_01/id_59/LeedCode_26_59.C# similarity index 100% rename from Week_01/id_59/LeedCode_26.cs rename to Week_01/id_59/LeedCode_26_59.C# diff --git a/Week_01/id_59/NOTE.md b/Week_01/id_59/NOTE.md index 624c19aa..bc4a6148 100644 --- a/Week_01/id_59/NOTE.md +++ b/Week_01/id_59/NOTE.md @@ -1,3 +1,11 @@ # 学习笔记 week_01 + +第一周听完老师讲解,不敢想,就是一门外汉,凑看热闹了,实在的之前没有接触算法类工作实践, +而学习积累也缺乏算法的阅读和思考,印象比较深的是2年前工作实践,使用了一个递归,后面想想才觉得是。 +因此,编程算法虽说实际应用比较,但有的话,用起来就不一样,那次使用递归完整权限的工作,花费过多时间, +才得以实现。 +也算是进来了这个课堂,模糊知道了学习态度与现有能力的差距,已经是第三周了,题目还没按量完成, +直至现在07.03才意识到自己推送代码上还存在问题,学习惰性太强了,学习难度也在,还是得加把劲, +在过程中也要挖掘其中乐趣,找到自己所热爱的事情,为之燃烧。__2019.07.03 Thu diff --git a/Week_02/id_59/LeedCode_1_59.C# b/Week_02/id_59/LeedCode_1_59.C# new file mode 100644 index 00000000..063a28c5 --- /dev/null +++ b/Week_02/id_59/LeedCode_1_59.C# @@ -0,0 +1,38 @@ +using System; + +public class LeedCode_1_59 +{ + public int[] TwoSum(int[] nums, int target) + { + int[] result = { 0, 0 }; + int less = 0; + int temp = 0; + int currentIndex = 0; + bool isRight = false; + foreach (var item in nums) + { + less++; + for (int i = less; i < nums.Length; i++) + { + temp = item + nums[i]; + if (temp == target) + { + result[0] = less - 1; + result[1] = i; + isRight = true; + } + } + if (!isRight) + { + currentIndex++; + } + else + { + break; + } + } + + return result; + } + +} diff --git a/Week_02/id_59/LeedCode_3_59.C# b/Week_02/id_59/LeedCode_3_59.C# new file mode 100644 index 00000000..c1d3cf9e --- /dev/null +++ b/Week_02/id_59/LeedCode_3_59.C# @@ -0,0 +1,59 @@ +using System; + +public class LeedCode_3_59 +{ + /// + /// 哈希表 + /// 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 + /// 示例 1: + /// 输入: "abcabcbb" + /// 输出: 3 + /// 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 + /// 来源:力扣(LeetCode) + /// 链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters + /// 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 + /// + /// + /// + public int LengthOfLongestSubstring(string s) + { + Stack tempStrCollect = new Stack(); + tempStrCollect.Push(""); + //Stack strCollect = new Stack(); + StringBuilder tempStr = new StringBuilder(); + for (int j = 0; j < s.Length; j++) + { + for (int i = j; i < s.Length; i++) + { + if (tempStr.ToString().IndexOf(s[i]) == -1) + { + tempStr.Append(s[i]); + } + else + { + //如何利用栈弹出与比较数值大小 + var tempStrCurrent = tempStr.ToString(); + //strCollect.Push(tempStrCurrent); + var tempStrBefore = tempStrCollect.Pop(); + if (tempStrBefore.Length < tempStrCurrent.Length) + { + tempStrCollect.Push(tempStrCurrent); + } + else + { + tempStrCollect.Push(tempStrBefore); + } + tempStr.Clear(); + break; + } + } + } + var maxStr = tempStrCollect.Pop().Length; + if (0 == maxStr) + { + maxStr = tempStr.Length; + } + + return maxStr; + } +} diff --git a/Week_02/id_59/NOTE.md b/Week_02/id_59/NOTE.md index 624c19aa..fa57d7b0 100644 --- a/Week_02/id_59/NOTE.md +++ b/Week_02/id_59/NOTE.md @@ -1,3 +1,10 @@ # 学习笔记 -week_01 +week_02 + +回想了下,自己做的第一道题目,足足坚持了三天,是挤出清晨+夜晚得时间去思考+动手尝试, +才把题目解出来,想想,前人已经把题目解决,有比我更好得解答速度+高效得解决方案,为何我还在花费三天 +的时间在这些重复问题上??? +学习速度慢+差距巨大+学习难度高,也许是我目前遇到的问题,另外,思考我自己真正想做的、热爱做的事情也许才是 +更加重要的事情,我上线下课已经有想法,想知道超哥的过往以及个人价值观+追求, +且行且思考,唔生有崖而学海无涯。加油! __2019.07.03 (补) diff --git a/Week_03/id_59/LeedCode_102_59.cs b/Week_03/id_59/LeedCode_102_59.cs new file mode 100644 index 00000000..89e083a6 --- /dev/null +++ b/Week_03/id_59/LeedCode_102_59.cs @@ -0,0 +1,51 @@ +using System; + +public class LeedCode_102_59 +{ + /** + * 给定一个二叉树,返回其按层次遍历的节点值。 (即逐层地,从左到右访问所有节点)。 + * 例如: + * 给定二叉树: [3,9,20,null,null,15,7], + + 3 + / \ + 9 20 + / \ + 15 7 + + 来源:力扣(LeetCode) + 链接:https://leetcode-cn.com/problems/binary-tree-level-order-traversal + 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 + * + * + */ + public List> LevelOrder(TreeNode root) + { + List> s = new List>(); + OrderNum(root, 0, s); + return s; + } + + /// + /// 覃老师,我这里编译其实没有通过在线的leedcode,但本地可以正常运行,求指教 + /// 说是IList无法隐式转换为List + /// + /// + /// + /// + public void OrderNum(TreeNode root, int depth, List> collect) + { + if (null != root) + { + if (depth >= collect.ToArray().Length) + { + collect.Add(new List()); + } + collect[depth].Add(root.val); + OrderNum(root.left, depth + 1, collect); + OrderNum(root.right, depth + 1, collect); + } + + } + +} diff --git a/Week_03/id_59/LeedCode_104_59.C# b/Week_03/id_59/LeedCode_104_59.C# new file mode 100644 index 00000000..309fdaa3 --- /dev/null +++ b/Week_03/id_59/LeedCode_104_59.C# @@ -0,0 +1,13 @@ +using System; + +public class LeedCode_104_59 +{ + public int MaxDepth(BTreeNode root) + { + if(null == root) + return 0; + var left = MaxDepth(root.left)+1; + var right = MaxDepth(root.right) + 1; + return left > right ? left : right; + } +} diff --git a/Week_03/id_59/NOTE.md b/Week_03/id_59/NOTE.md index 624c19aa..01f0881b 100644 --- a/Week_03/id_59/NOTE.md +++ b/Week_03/id_59/NOTE.md @@ -1,3 +1,19 @@ # 学习笔记 -week_01 +week_03 + +本周做题极度缓慢了,学习的热火已经如蜡烛般微弱,应该是学习的乐趣和自我激励上没有达到。 +另外个人惰性也开始回来了,当然这个是相较于第一周时学习的热情,因为,在老师直播评价其他同学 +作业中,也看见了他人提交作业的质量、数量上也是大大超出自己想象,在老师感到欣慰的同时,我个人 +学习的意向好像被眼前的他人的成绩打败了,差距真的越拉越大的感觉,有时真的,一道简单的二叉树, +自己也是想了好三天。 +在这周自己也学习广州的同学,约了深圳线下一名高手,几乎每周的题目刷个光,而且还有自己的自主选择, +一些较为偏僻的题目,就先暂缓花时间上去,这个对于我们成年人、已工作人士而言,也比较确切的问题, +时间的宝贵性,在持续的努力过后,收益甚微,会极大挫伤走下去的勇气。 +说到实质上的问题: +1、上下班后精神、体力、脑力的下降 +2、算法与数据结构的基础薄弱 +3、计算机基本素养有待提升 +4、对于学习职业规划,个人发展,以及目前的学习算法,少了恒心 +收获: +二叉树的递归求深度稍微了解。 \ No newline at end of file diff --git a/Week_04/id_59/LeedCode_455_59.c# b/Week_04/id_59/LeedCode_455_59.c# new file mode 100644 index 00000000..5fe5cf2a --- /dev/null +++ b/Week_04/id_59/LeedCode_455_59.c# @@ -0,0 +1,42 @@ +using System; + +/** + * /** + * 假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。 + * 对每个孩子 i ,都有一个胃口值 gi ,这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 j , + * 都有一个尺寸 sj 。如果 sj >= gi ,我们可以将这个饼干 j 分配给孩子 i ,这个孩子会得到满足。 + * 你的目标是尽可能满足越多数量的孩子,并输出这个最大数值。 +来源:力扣(LeetCode) +链接:https://leetcode-cn.com/problems/assign-cookies +著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 + * **/ + +public class LeedCode_455_59 +{ + /// + /// 真的参考了LY_liuxiaobei 一看就知会了这个解法的神奇之处 + /// + /// + /// + /// + public int FindContentChildren(int[] g, int[] s) + { + Array.Sort(g); + Array.Sort(s); + int i = 0, j = 0; + while (i < g.Count() && j < s.Count()) + { + if (g[i] <= s[j]) + { + i++; + j++; + } + else + { + j++; + } + } + + return i; + } +} diff --git a/Week_04/id_59/LeedCode_70_59.C# b/Week_04/id_59/LeedCode_70_59.C# new file mode 100644 index 00000000..5c681c82 --- /dev/null +++ b/Week_04/id_59/LeedCode_70_59.C# @@ -0,0 +1,35 @@ +using System; + +//You are climbing a stair case. It takes n steps to reach to the top. + + //Each time you can either climb 1 or 2 steps.In how many distinct ways can you climb to the top? + + //Note: Given n will be a positive integer. + + //Example 1: + + //Input: 2 + //Output: 2 + //Explanation: There are two ways to climb to the top. + //1. 1 step + 1 step + //2. 2 steps + +public class climbingStatir +{ + //basic + if (0 > n) return 0; + if (1 == n) return 1; + if (2 == n) return 2; + + var dp = new int[n]; + + dp[0] = 1; + dp[1] = 2; + + for (int i = 2; i < n; i++) + { + dp[i] = dp[i - 1] + dp[i - 2]; + } + + return dp[n - 1]; +} diff --git a/Week_04/id_59/NOTE.md b/Week_04/id_59/NOTE.md index 624c19aa..24fea5bb 100644 --- a/Week_04/id_59/NOTE.md +++ b/Week_04/id_59/NOTE.md @@ -1,3 +1,16 @@ # 学习笔记 -week_01 +week_4 +最后一周的作业,在调休的周一,坚持了一天的情况下,超常完成了三道题,当然是 +在自己思考无果的情况下,借鉴了题解以及相关的评论然后完成,在自己思考尝试没有完成测试, +偷看他们的做法,会得到一种震撼感,真的人家的孩子,不是没有道理的,感觉他们是真算法了, +自己的拖拉机式思考,完全完完全全被击败了,难得自己今天调休可以在外面待上一个白天,但是 +我们时间不多了,人生的事情还很多,钱包还没鼓起来,真的是有时做题也是挺高成本的,但是不做, +待在屋里貌似也不会有太大的进展, +还是出外结识一些朋友,做业务,在其他方面腾飞吗?发展吗? +今天在深圳音乐厅的星巴克附近,发生两起, +一个是在大中午的闹事,被Sir抓啊,喊啊,想想也是累啊 +另外一个就是,两个类似三和大神的人物,就赖在椅子上睡了起来了,其实,大热天的, +我也是溜出来叹空调,可是,老哥他更厉害,直接睡上了, +芸芸众生啊,苦生相, +说了些题外话 __2019.07.15 18:25:51