自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 收藏
  • 关注

原创 [leetcode] 21. 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.SolutionIdea: create a new list, then compare the val

2016-06-03 12:20:51 265

原创 [leetcode] 121. Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2016-06-03 10:36:31 163

原创 [leetcode] 141. Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Solution 1:Idea: construct a hash table using unordered_map/** * Definiti

2016-06-03 07:05:03 172

原创 [leetcode] 202. Happy Number

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, replace the number by the sum of the squares

2016-06-03 06:52:26 180

原创 [leetcode] 70. Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Solution 1idea: recursiv

2016-06-02 12:16:29 216

原创 [leetcode] 83. Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.Solution:Compare th

2016-06-02 11:39:11 169

原创 [leetcode] 263. 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 si

2016-06-02 11:26:20 283

原创 [leetcode] 231. Power of Two

Given an integer, write a function to determine if it is a power of two.Solution 1Idea: divide n by 2, and check the residual. class Solution {public: bool isPowerOfTwo(int n) {

2016-06-02 11:10:41 245

原创 [leetcode] 326. Power of Three

Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?check n =? 3^xSolution 1Idea: divide 3 to see w

2016-06-02 10:43:03 182

原创 [leetcode] 191. 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 000000

2016-06-02 10:16:08 168

原创 [leetcode] 235. Lowest Common Ancestor of a Binary Search Tree

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betw

2016-06-01 12:23:34 193

原创 [leetcode] 13. Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.any of the letters representing numbers in the Roman numerical system: I = 1, V = 5, X

2016-06-01 12:13:02 238

原创 [leetcode] 206. Reverse Linked List

Reverse a singly linked list.Solution 1Idea: create a dummy node and insert node after dummy node /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode

2016-06-01 11:35:12 544

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除