摘要: Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Example 2: 算法: 1. 递增法。用 阅读全文
posted @ 2017-11-29 15:29 jasminemzy 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they 阅读全文
posted @ 2017-11-29 15:04 jasminemzy 阅读(106) 评论(0) 推荐(0) 编辑
摘要: You need to find the largest value in each row of a binary tree. Example: 算法: 1.BFS。层级遍历,每层打擂台。 2.DFS。记录从上到下的深度,每层参数里传下去+1即可。(从下到上的深度是通过回传int返回值来递归实现的 阅读全文
posted @ 2017-11-29 14:21 jasminemzy 阅读(123) 评论(0) 推荐(0) 编辑
摘要: In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach o 阅读全文
posted @ 2017-11-29 11:57 jasminemzy 阅读(237) 评论(0) 推荐(0) 编辑
摘要: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston 阅读全文
posted @ 2017-11-29 09:13 jasminemzy 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio 阅读全文
posted @ 2017-11-29 08:21 jasminemzy 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty. Example:Given bi 阅读全文
posted @ 2017-11-29 07:53 jasminemzy 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is equal to B's row number. Example: A = [ [ 1, 0, 0 阅读全文
posted @ 2017-11-29 05:02 jasminemzy 阅读(93) 评论(0) 推荐(0) 编辑