摘要: Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For 阅读全文
posted @ 2016-02-24 17:49 Ray.Yang 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2- 阅读全文
posted @ 2016-02-22 16:24 Ray.Yang 阅读(121) 评论(0) 推荐(0) 编辑
摘要: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single 阅读全文
posted @ 2016-02-04 14:19 Ray.Yang 阅读(209) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two n 阅读全文
posted @ 2016-02-02 17:47 Ray.Yang 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 虽然MVC架构已经火了很多年了。。但我一直没有机会真正去体会其本质,借现在得机会,转一篇MVC架构的初学篇 控制器(books_controller.php)以HTTP GET或者POST的方式接收到用户的请求(我们也可以有一个主控制器,比如index.php 来接收请求,然后它再调用ooks_co 阅读全文
posted @ 2016-02-02 15:47 Ray.Yang 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be for 阅读全文
posted @ 2016-02-01 16:22 Ray.Yang 阅读(352) 评论(0) 推荐(0) 编辑
摘要: 给定任意随机数,判定是否为3的乘方。 1. 递归 public class Solution { public boolean isPowerOfThree(int n) { if (n == 1) return true; if (n % 3 >0 || n == 0) return false; 阅读全文
posted @ 2016-01-28 16:47 Ray.Yang 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文
posted @ 2016-01-28 16:20 Ray.Yang 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 汉诺塔的问题 汉诺塔问题是源于印度一个古老传说的益智玩具。大梵天创造世界的时候做了三根金刚石柱子,在一根柱子上从下往上按照大小顺序摞着64片黄金圆盘。大梵天命令婆罗门把圆盘从下面开始按大小顺序重新摆放在另一根柱子上。并且规定,在小圆盘上不能放大圆盘,在三根柱子之间一次只能移动一个圆盘。或许下面的解释 阅读全文
posted @ 2016-01-28 14:26 Ray.Yang 阅读(229) 评论(0) 推荐(0) 编辑
摘要: Question: Assume that we have linked list 1 → 2 → 3 → Ø, we would like to change it to Ø ← 1 ← 2 ← 3 Official Solution: While you are traversing the l 阅读全文
posted @ 2016-01-27 16:29 Ray.Yang 阅读(159) 评论(0) 推荐(0) 编辑