2018-01-17 Vaniot
2014-04-29 veryyoung
题目链接: http://oj.leetcode.com/problems/two-sum/ 题目内容: 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 numbers such that they add up to the target, where index1 must be less than index2. Please note that your return 继续阅读 »
2016-07-01 YongHao Hu
C++
344. Reverse String Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". 继续阅读 »
2015-12-13 MoreFreeze
I have trained my algorithm on leetcode a period of time. Today, I will explain my solution about Minimum Height Trees. My solution beat ~95% against others but it is hard to explain what is I do. Please allow me to introduce the solution from easy to hard. If you only need the last solution, jump to 继续阅读 »
2016-09-17 crane-yuan
题目描述 给定一个已排序的单链表,去除单链表中的重复元素,只保留一个重复的元素,并且返回新的单链表。 例如: 给出1->1->2,你的函数调用之后必须返回1->2。 输入 一个已排序的单链表,例如1->1->2。 输出 返回1->2。 代码示例 ``` java /** 单链表定义 * * @author: crane-yuan * @date: 2016-9-17 下午12:11:13 */ public class ListNode { public int val; public ListNode next; public ListNode(int x) { val = x; 继续阅读 »
2016-10-12 crane-yuan
基本问题 如何删除单链表中的倒数第n个节点? 常规解法 先遍历一遍单链表,计算出单链表的长度,然后,从单链表头部删除指定的节点。 more 代码实现 ``` java /** 删除单链表倒数第n个节点,常规解法. * * @param head * @param n * @return ListNode */ public static ListNode removeNthFromEnd(ListNode head, int n) { if(head == null) { return null ; } //get length of list ListNode p 继续阅读 »
2016-10-10 crane-yuan
基本问题 如何将单链表反转? 单链表结构定义 ``` java /** 单链表定义 * * @author: crane-yuan * @date: 2016-9-17 下午12:11:13 */ public class ListNode { public int val; public ListNode next; public ListNode(int x) { val = x; } } ``` more 算法实现 java /** 单链表反转 * * @param head * @return ListNode */ public static ListNode rever 继续阅读 »
2014-09-11 veryyoung
书籍整理: 程序员面试金典(第5版).pdf http://vdisk.weibo.com/s/D2zXXYpTKPKx 程序员编程艺术— 面试和算法心得pdf版 http://url.cn/M3vj4Z 刷题oj: leetcode http://oj.leetcode.com/problems/ 刷剑指offer http://ac.jobdu.com/hhtproblems.php# Java 内存区域和GC机制 http://www.cnblogs.com/zhguang/p/3257367.html#introduction http://www.ibm.com/developerworks/cn/ja 继续阅读 »
2016-05-18 crane-yuan
Question Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation 00000000000000000000000000001011, so the function should return 3. 解说 这道题的意思是统计32位整数二进制格式下的‘1’的个数。 more Solution rig 继续阅读 »
2016-06-06 crane-yuan
Question Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will always be valid. Try to do this in one pass. 解说 这道题的意思是,如何反向删 继续阅读 »