文章分类 -  数据结构

这里是我之前在leetcode上面练习的题,最近闲来无事,就记录下来了
摘要:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below a... 阅读全文
posted @ 2015-05-14 14:27 F-happy 阅读(101) 评论(0) 推荐(0) 编辑
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文
posted @ 2015-05-14 14:23 F-happy 阅读(97) 评论(0) 推荐(0) 编辑
摘要:Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return –321解题思路: 题目的意思是要将一个整数反转, 当反转后的数 溢出时返回0。注意:这里要注意的是反转后是否会越界。class... 阅读全文
posted @ 2015-05-14 14:20 F-happy 阅读(69) 评论(0) 推荐(0) 编辑
摘要:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font ... 阅读全文
posted @ 2015-05-14 14:16 F-happy 阅读(137) 评论(0) 推荐(0) 编辑
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文
posted @ 2015-05-14 14:08 F-happy 阅读(104) 评论(0) 推荐(0) 编辑
摘要:Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 v2: return 1 if v1 < v2: ... 阅读全文
posted @ 2015-05-14 14:01 F-happy 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ->... 阅读全文
posted @ 2015-05-14 13:55 F-happy 阅读(76) 评论(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 @ 2015-05-14 13:50 F-happy 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A... 阅读全文
posted @ 2015-05-14 13:44 F-happy 阅读(111) 评论(0) 推荐(0) 编辑
摘要:Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.解题思路: 题目很简单明了,就是给定N,求N!的末尾... 阅读全文
posted @ 2015-05-14 11:03 F-happy 阅读(102) 评论(0) 推荐(0) 编辑
摘要:Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:... 阅读全文
posted @ 2015-05-14 10:46 F-happy 阅读(116) 评论(0) 推荐(0) 编辑
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return... 阅读全文
posted @ 2015-05-14 10:42 F-happy 阅读(98) 评论(0) 推荐(0) 编辑
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... 阅读全文
posted @ 2015-05-14 10:29 F-happy 阅读(110) 评论(0) 推荐(0) 编辑
摘要:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
posted @ 2015-05-14 10:24 F-happy 阅读(112) 评论(0) 推荐(0) 编辑
摘要:The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11. 11 is read... 阅读全文
posted @ 2015-05-14 10:19 F-happy 阅读(105) 评论(0) 推荐(0) 编辑
摘要: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 i... 阅读全文
posted @ 2015-05-11 17:47 F-happy 阅读(89) 评论(0) 推荐(0) 编辑
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, "A man, a plan, a canal: Pan... 阅读全文
posted @ 2015-05-11 17:28 F-happy 阅读(105) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示