摘要: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 - 阅读全文
posted @ 2016-09-11 05:51 Machelsky 阅读(103) 评论(0) 推荐(0)
摘要: 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 is like: 阅读全文
posted @ 2016-09-11 05:34 Machelsky 阅读(149) 评论(0) 推荐(0)
摘要: Invert a binary tree. to 阅读全文
posted @ 2016-09-11 05:14 Machelsky 阅读(123) 评论(0) 推荐(0)
摘要: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size tha 阅读全文
posted @ 2016-09-11 04:02 Machelsky 阅读(164) 评论(0) 推荐(0)
摘要: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, giv 阅读全文
posted @ 2016-09-11 03:18 Machelsky 阅读(159) 评论(0) 推荐(0)
摘要: Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Solution1: 这道题做的太麻烦了,corner case很多,碰到负数不知道怎么给reverse。强行转成st 阅读全文
posted @ 2016-09-11 03:00 Machelsky 阅读(154) 评论(0) 推荐(0)
摘要: Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Solution1: 不使用任何functiion 昨天 阅读全文
posted @ 2016-09-10 12:06 Machelsky 阅读(144) 评论(0) 推荐(0)
摘要: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 思路:之前一直觉得罗马数字好麻烦,一刷的时候看到就头疼不想做。看了看wiki之后感觉 阅读全文
posted @ 2016-09-10 10:49 Machelsky 阅读(520) 评论(0) 推荐(0)
摘要: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2016-09-10 09:27 Machelsky 阅读(114) 评论(0) 推荐(0)
摘要: Reverse a singly linked list. Solution 1: 思路:null的使用。用一个null node来承接,一个一个接上去即可。一刷的时候还觉得这node转化好麻烦好神奇,熟悉之后其实做起来很快。 Solution 2: follow up : Use Recursio 阅读全文
posted @ 2016-09-10 08:32 Machelsky 阅读(100) 评论(0) 推荐(0)