[LeetCode] Single Number
Single NumberGiven an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it ...
[LeetCode] Contains Duplicate III
Contains Duplicate IIIGiven an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and n...
[LeetCode] Word Break
Word BreakGiven a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens&...
[LeetCode] Rectangle Area
Rectangle AreaFind the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figur...
[LeetCode] Count Complete Tree Nodes
Count Complete Tree NodesGiven a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possib...
Win Phone 8.1 模拟器联网
环境:windows 8 server版本,vs2013状况:模拟器不能联网,而宿主主机联网正常。解决办法:(1)打开Hyper-V Manager,找到自己的模拟器(我们用服务器多用户开发,找到自身的那个即可)。(2)右键-》设置,在弹出的框中,添加一些虚拟网卡。一般默认会有几个。(3)打开互联网共享中心,找到实际的网卡,属性,选择共享标签,勾选允许其他互联网用户连接网络,选择其中一个虚拟网卡,...
[LeetCode] Basic Calculator
Basic CalculatorImplement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sig...
[LeetCode] Invert Binary Tree
Invert Binary TreeInvert a binary tree. 4 / \ 2 7 / \ / \ ...
[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 elemen...
[LeetCode] Linked List Cycle II
Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?解题思路:1、解法1,用set来存储所有已经出现的指针...
[LeetCode] Linked List Cycle
Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?解题思路:1、最基本的办法是用一个set来存储所有已经出现过的指针。若出现重复,则表示有环,若没有重复,则没有环。/** * ...
用两个栈实现队列的功能
用两个栈实现队列的功能思路如下:(1)将设有两个空栈A,B;A负责入队,B负责出队。(2)入队时,将元素压入栈A(3)出队时,若B栈为空,将A中的元素全部出栈,并压入B中,然后B的栈顶元素出栈。若B栈不为空,直接将B的栈顶元素出栈。
[LeetCode] Contains Duplicate II
Contains Duplicate II Given an array of integers and an integer k, return true if and only if there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference be...
心愿
[LeetCode] Reorder List
Reorder ListGiven 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 example,Given {...
[LeetCode] Binary Tree Preorder Traversal (非递归的先序遍历)
Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 ...
北京东路的日子
[LeetCode] Insertion Sort List
Insertion Sort ListSort a linked list using insertion sort.解题思路:类似于插入排序法。与数组的插入排序法不同的是,链表的插入排序扫描顺序是从左往右扫描,找到第一个大于指定元素的节点N,然后将之插在N节点前面。今天状态非常不好,这个题目都NG了好几遍。。。/** * Definition for ...
[LeetCode] Jump Game
Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine ...
[LeetCode] Maximum Subarray
Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarra...