摘要: Problem: Invert a binary tree. to Analysis: 1、helper function + recursion 一开始我用调用子函数,在子函数中递归的方式实现: 虽然解决了问题,但效率太低 2、recursion 进而将递归写入主函数中,并简化了部分代码 效率有所 阅读全文
posted @ 2016-10-24 12:23 SillyVicky 阅读(153) 评论(0) 推荐(0)
摘要: Problem: Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more l 阅读全文
posted @ 2016-10-24 11:28 SillyVicky 阅读(140) 评论(0) 推荐(0)
摘要: Problem: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process 阅读全文
posted @ 2016-10-23 02:04 SillyVicky 阅读(154) 评论(0) 推荐(0)
摘要: Problem: 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 阅读全文
posted @ 2016-10-23 02:01 SillyVicky 阅读(152) 评论(0) 推荐(0)
摘要: Problem: Given an array of integers, every element appears twice except for one. Find that single one. Your algorithm should have a linear runtime com 阅读全文
posted @ 2016-10-23 02:00 SillyVicky 阅读(170) 评论(0) 推荐(0)
摘要: Problem: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Summary: 不使用+和-符号,计算两个整型数之和。 Analysis: XOR相当于 阅读全文
posted @ 2016-10-23 01:59 SillyVicky 阅读(133) 评论(0) 推荐(0)
摘要: Problem: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the f 阅读全文
posted @ 2016-10-23 01:57 SillyVicky 阅读(168) 评论(0) 推荐(0)