题目地址 https://leetcode.com/problems/nim-game/ 题目大意 和好朋友玩游戏,桌子上与很多棋子,每个人轮流拿棋子,可以拿1个、2个或3个,拿走最后一个棋子的人获胜。假设你和你的好朋友…
标签:LeetCode
LeetCode Math算法题(Easy级别)整理 Part 2
172. Factorial Trailing Zeroes 题目简介:给定一个数n,求n!的结尾连续的0的个数。 解题思路:通过观察可得,0只可能由2和5相乘获得,而5的个数总是小于等于2的个数,所以问题就转为了寻找n…
LeetCode Math算法题(Easy级别)整理 Part 1
7. Reverse Integer 题目简介:翻转一个数字的数字部分的字符,即负数的“-”位置不变,只翻转数字部分。当翻转后的数字溢出时(超过32有符号整数的范围),返回0。 解题思路:将数字转成字符串,利用字符串的翻…
LeetCode Array算法题(Easy级别)整理 Part 2
本篇整理的为Array算法题(Easy级别)的第二部分,这些题对我而言更有启发性,提高了思维的灵活性。如有纰漏,敬请指出,也欢迎交流分享更好的算法~。 1. Two Sum 题目简介:给定一串数(nums)和一个目标数(…
Leetcode #407 Trapping Rain Water
Leetcode #407 Trapping Rain Water II 问题描述 给出一个n*m的矩阵表示一块区域的地形,每个格子的数值表示这个格子所代表的地势高度。 问对于这样的一个矩阵,最多能储备多少的水? 算法分…
【Leetcode 做题学算法周刊】第一期
首发于微信公众号《前端成长记》,写于 2019.10.28 背景 本文记录刷题过程中的整个思考过程,以供参考。主要内容涵盖: 题目分析设想 编写代码验证 查阅他人解法 思考总结 目录 1.两数之和 7.整数反转 9.回文…
LeetCode日常刷题(3)
7. Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321…
LeetCode日常刷题(2)
4. Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find …
Leetcode: 133. Clone Graph(Week6, Medium)
注:本题使用BFS算法 Leetcode 133 Clone an undirected graph. Each node in the graph contains a label and a list of its …
Leetcode: 130. Surrounded Region(Week7, Medium)
注: 本题使用BFS算法求解 Leetcode 130 Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrou…
Leetcode: 34. Search for range(Week9, Medium)
注:本题采用二分法的思想 Leetcode 34 Given an array of integers sorted in ascending order, find the starting and ending po…
leetcode 4. Median of Two Sorted Arrays笔记
题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted…