leetcode
文章平均质量分 74
spencersong
疯狂撸码中
展开
-
LeetCode874:机器人路径模拟
题目:A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands:-2: turn left 90 degrees -1: turn right 90 degrees 1 <= x...原创 2018-10-23 16:33:23 · 954 阅读 · 0 评论 -
leetcode 746.爬楼梯的最小代价(从暴力递归到动态规划)
题目:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the to...原创 2018-10-26 08:33:01 · 760 阅读 · 0 评论 -
leetcode343. Integer Break
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.题目大意是说给定一个正整数n,将其拆分成正好等于至少2个正整数...原创 2018-11-29 22:58:55 · 828 阅读 · 0 评论 -
二分查找没有变形
二分查找没有变形经典的二分查找相信大家都已烂熟于心,但是经典的二分查找只给出了true或false的回答,也就是是否存在,存在返回true,不存在则返回false。但是,基于经典的二分查找却会有很多的变式,每一种变式可能都会有相应的代码解决方案,本文之所以命名为"二分查找没有变形",是因为我找到了一个统一的思路,无论哪种变形都能根据此思路写出相应的代码。本文默认约束是从数组中查找某一个...原创 2019-09-16 14:24:27 · 152 阅读 · 0 评论 -
leetcode 114. Flatten Binary Tree to Linked List
leetcode 114. Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flatten...原创 2019-09-16 14:26:05 · 136 阅读 · 0 评论