自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 资源 (4)
  • 收藏
  • 关注

原创 144. Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].递归实现:/** * Defini

2016-03-31 18:53:18 400

原创 319. Bulb Switcher

There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off

2016-03-31 11:51:39 207

原创 238. Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O

2016-03-30 13:30:27 266

原创 260. Single Number III

Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given 

2016-03-30 12:13:27 198

原创 338. Counting Bits

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num =

2016-03-30 00:23:55 287

原创 189. Rotate Array

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:Try to come up as many solutions as yo

2016-03-29 12:04:52 237

原创 8. 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 the possible input ca

2016-03-28 00:45:46 204

原创 155. Min Stack

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 the element on top of the stack.top() -- Get

2016-03-27 23:26:12 185

原创 278. First Bad Version

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the

2016-03-26 23:52:30 319

原创 1. Two Sum

Given 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 =

2016-03-25 20:37:24 227

原创 6. ZigZag Conversion

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 for better legibility)P A H NA P L S I

2016-03-25 20:05:15 216

原创 204. Count Primes

Description:Count the number of prime numbers less than a non-negative number, n.本以为是个求素数的大水题,想都没想直接写了下面代码,结果直接TLE。class Solution {public: int countPrimes(int n) { if(n<2)retu

2016-03-24 16:15:23 189

原创 228. Summary Ranges

iven a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].题意就是连续的一段数字为一个区域,即 nums[j]+1==nums[j+1]class Sol

2016-03-23 21:34:40 203

原创 303. Range Sum Query - Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan

2016-03-23 19:38:00 214

原创 28. Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.题目就是 字符串匹配。我觉得这个题目主要是学习回顾了一下经典的KMP算法吧,这个算法感觉一段时间不看,就又忘了。。

2016-03-23 17:26:11 191

原创 67. Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".用大数加法的思想,按位相加。class Solution {public: string addBinary(string a, string b

2016-03-23 16:02:06 328

原创 234. Palindrome Linked List(链表模板)

Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?思路1:遍历一边链表,把它放到数组或VECTOR里,转化为字符串的回文判断。但是时间复杂度和空间复杂度都是O(n)。class Solution

2016-03-23 15:33:07 283

原创 14. Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.Subscribe to see which companies asked this question求最长公共子串。思路:可以把它想象成一个二维的字符数组,我们一列一列的遍历。如果一列有一个数和第

2016-03-22 23:38:06 287

原创 257. Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]二叉树的遍历,下面

2016-03-21 21:56:12 299

原创 203. Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special than

2016-03-21 20:45:44 270

原创 38. Count and Say

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 off as "two 1s" or 21.21 is read off as 

2016-03-20 13:15:48 239

原创 网易2016研发工程师编程题 扫描透镜

在N*M的草地上,提莫种了K个蘑菇,蘑菇爆炸的威力极大,兰博不想贸然去闯,而且蘑菇是隐形的.只 有一种叫做扫描透镜的物品可以扫描出隐形的蘑菇,于是他回了一趟战争学院,买了2个扫描透镜,一个 扫描透镜可以扫描出(3*3)方格中所有的蘑菇,然后兰博就可以清理掉一些隐形的蘑菇. 问:兰博最多可以清理多少个蘑菇?输入描述:第一行三个整数:N,M,K,(1≤N,M≤20,K≤100),N,M

2016-03-19 17:37:26 718

原创 网易校招笔试题 小易的升级之路

小易经常沉迷于网络游戏.有一次,他在玩一个打怪升级的游戏,他的角色的初始能力值为 a.在接下来的一段时间内,他将会依次遇见n个怪物,每个怪物的防御力为b1,b2,b3...bn. 如果遇到的怪物防御力bi小于等于小易的当前能力值c,那么他就能轻松打败怪物,并 且使得自己的能力值增加bi;如果bi大于c,那他也能打败怪物,但他的能力值只能增加bi 与c的最大公约数.那么问题来了,在一系列的锻炼后

2016-03-19 17:10:14 1104

原创 网易校招笔试题 炮台攻击

兰博教训提莫之后,然后和提莫讨论起约德尔人,谈起约德尔人,自然少不了一个人,那 就是黑默丁格------约德尔人历史上最伟大的科学家. 提莫说,黑默丁格最近在思考一个问题:黑默丁格有三个炮台,炮台能攻击到距离它R的敌人 (两点之间的距离为两点连续的距离,例如(3,0),(0,4)之间的距离是5),如果一个炮台能攻击 到敌人,那么就会对敌人造成1×的伤害.黑默丁格将三个炮台放在N*M方格中的点上

2016-03-19 17:08:52 1379

原创 290. Word Pattern

Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.

2016-03-19 16:37:24 240

原创 易互娱2017实习生招聘在线笔试第一场题目1 : 电子数字

时间限制:10000ms单点时限:1000ms内存限制:256MB描述电子数字在生活中很常见,而许多的电子数字是由LED数码管制作而成。数字LED数码管一般由7个发光二极管封装在一起,组成'8'字型,引线在内部连接完成。如下图所示,我们可以对每个发光管进行编码从1到7。而数字0到数字9可以由这七根发光管的亮暗来表示。对LED数码管的二极管进行编码

2016-03-19 00:40:59 782 3

原创 299. Bulls and Cows

You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint t

2016-03-18 21:34:11 248

原创 58. Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is

2016-03-18 20:48:50 232

原创 20. Valid Parentheses

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va

2016-03-18 19:48:06 226

原创 19. Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2016-03-17 15:53:13 195

原创 205. Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with anot

2016-03-17 15:27:57 246

原创 219. Contains Duplicate II

Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and jis at most k.一

2016-03-16 23:57:02 211

原创 225. Implement Stack using Queues

mplement 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.empty() -- Return wheth

2016-03-16 13:33:30 255

原创 112. Path Sum

112. Path SumMy SubmissionsQuestionTotal Accepted: 94794 Total Submissions: 305442 Difficulty: EasyGiven a binary tree and a sum, determine if the tree has a root-to-leaf path

2016-03-15 23:56:30 256

原创 118. Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]Subscribe to see

2016-03-14 21:20:07 199

原创 101. Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f

2016-03-13 14:43:18 213

原创 198. House Robber

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 you from robbing each of them is that adjacent house

2016-03-13 12:37:49 240

原创 110. Balanced Binary Tree

110. Balanced Binary TreeMy SubmissionsQuestionTotal Accepted: 101551 Total Submissions: 301899 Difficulty: EasyGiven a binary tree, determine if it is height-balanced.For th

2016-03-13 11:00:21 271

原创 232. Implement Queue using Stacks

Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(

2016-03-12 23:05:30 232

原创 21. Merge Two Sorted Lists

21. Merge Two Sorted ListsMy SubmissionsQuestionTotal Accepted: 114471 Total Submissions: 327808 Difficulty: EasyMerge two sorted linked lists and return it as a new list. The

2016-03-12 22:17:58 220

SQL基础教程

非常好的一个SQL基础教程,我自己看了 觉得比较有用

2014-09-18

组成原理课程设计

重点院校的计算机组成原理课程设计报告,比较详细

2014-09-18

C语言经典小程序

上百个C语言的经典题和代码,十分适合初学C语言的同学

2011-12-07

空空如也

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

TA关注的人

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