- 博客(26)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode|Gray Code
Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence
2016-04-30 19:45:22 2256
转载 LeetCode|Valid Number
Valid Number判断合法数字 (https://github.com/fuwutu/LeetCode/blob/master/Valid%20Number.cpp),用有限状态机,非常简洁,不需要复杂的各种判断!先枚举一下各种合法的输入情况:1.空格+ 数字 +空格2.空格+ 点 + 数字 +空格3.空格+ 符号 + 数字 + 空格
2016-04-30 11:36:04 410
原创 LeetCode|String to Integer (atoi)
String to Integer (atoi) 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 and ask yourself what are t
2016-04-30 11:23:40 377
原创 LeetCode|Convert * to Binary Search Tree
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:递归找中点做rootclass Solution {public: TreeNode* sortedArra
2016-04-30 11:08:47 387
原创 LeetCode|Triangle
Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle [ [2], [3
2016-04-30 09:05:13 319
原创 LeetCode|Ugly Number*
Ugly Number Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly
2016-04-29 21:27:51 390
原创 LeetCode|Min Stack
Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() –
2016-04-28 22:13:19 555
原创 LeetCode|Valid Parentheses
Valid ParenthesesGiven a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the correct order, “()” and “()[]{}” ar
2016-04-26 08:01:18 370
原创 LeetCode|*Sum
Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example: Given nums = [2,
2016-04-24 22:55:14 390
转载 我的美国CS面试经验分享(转载)
过去的一年多里,参加了一些面试,虽然面过的公司不多,但都从头一直走到尾。毕竟自己也是花了大量的时间和精力在这一场场的面试里。所以,就絮叨下自己的一些经验,希望能给在美国找实习找工作的同学们提供一点点帮助。开始前的一些说明: 1. 笔者只是一介小本,虽然留了学,但是留了级,学识浅薄,目光短浅,文章若有不恰之处,恳请各位大牛不吝指正! 2. 笔者面试的岗位均为Software
2016-04-23 17:57:04 1276
原创 双指针法题目总结
Move ZeroesGiven 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, given nums = [0, 1, 0, 3, 12], after calling
2016-04-23 17:48:12 719
原创 LeetCode|Count Primes
Count PrimesCount the number of prime numbers less than a non-negative number n.
2016-04-22 22:09:29 417
原创 二叉树题目总结
Invert Binary TreeInvert a binary tree.Recursion:class Solution {public: TreeNode* invertTree(TreeNode* root) { if(root == NULL) return NULL; swap(root->left, root->right);
2016-04-21 23:07:40 1384
原创 LeetCode|Implement Stack using Queues
Implement Stack using QueuesImplement the following operations of a stack using queues.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get the top element
2016-04-21 08:48:52 323
原创 LeetCode|Implement Queue using Stacks
Implement Queue using Stacks Implement the following operations of a queue using stacks.
2016-04-21 07:59:01 425
原创 LeetCode|Integer Break
Integer Break Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.
2016-04-21 07:50:50 421
原创 LeetCode|Merge Two Sorted Lists/Merge Sorted Array
Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.class Solution {public: ListNode
2016-04-19 23:15:11 369
原创 LeetCode|Majority Element *
Majority Element 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 array is non-empty and the major
2016-04-18 19:46:22 341
原创 LeetCode|Sliding Window Maximum
Sliding Window MaximumGiven an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time
2016-04-15 23:58:55 3890
原创 计算逆序对/逆序数
利用归并排序计算逆序对#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#include <algorithm>#include <stack>using namespace std;long long ans;i...
2016-04-15 23:50:37 1309
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人