發表文章

目前顯示的是 10月, 2015的文章

Leetcode:Invert Binary Tree

Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was inspired by this original tweet by Max Howell : Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.

Leetcode:Number of 1 Bits

Number of 1 Bits 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.

Leetcode:Same Tree

Same Tree Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value.

Leetcode:Delete Node in a Linked List

Delete Node in a Linked List 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 -> 4 and you are given the third node with value 3 , the linked list should become 1 -> 2 -> 4 after calling your function.

Leetcode:Single Number

Single Number Given 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 without using extra memory?

Leetcode:Maximum Depth of Binary Tree

Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

Leetcode:Pascal's Triangle II

圖片
Pascal's Triangle II  Given an index k, return the  k th  row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1].  Note: Could you optimize your algorithm to use only O(k) extra space?