自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

魔豆(Magicbean)的博客

分享计算机专业的相关知识

  • 博客(39)
  • 收藏
  • 关注

原创 [Leetcode] 37. Sudoku Solver 解题报告

题目:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.

2016-12-30 07:23:13 586

原创 [Leetcode] 36. Valid Sudoku 解题报告

题目:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partia

2016-12-29 06:50:07 420

原创 [Leetcode] 35. Search Insert Position 解题报告

题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in t

2016-12-29 06:42:12 413

原创 [Leetcode] 34. Search for a Range 解题报告

题目:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is n

2016-12-29 05:09:04 381

原创 [Leetcode] 33. Search in Rotated Sorted Array 解题报告

题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the ar

2016-12-28 00:46:52 872

原创 [Leetcode] 32. Longest Valid Parentheses 解题报告

题目:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is

2016-12-18 00:48:31 795

原创 [Leetcode] 31. Next Permutation 解题报告

题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest

2016-12-17 00:37:17 686

原创 [Leetcode] 30. Substring with Concatenation of All Words 解题报告

题目:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly

2016-12-17 00:03:06 328

原创 [Leetcode] 29. Divide Two Integers 解题报告

题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.思路:        我们在这里总结一下两种可能的思路(只考虑被除数和除数均为正数的情况):1、只要被除数大于等于除数,就从被除数中减去除数,

2016-12-15 09:28:19 793

原创 [Leetcode] 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.思路:1、暴力枚举法:从haystack的开头试图匹配,如果匹配完成则返回;否则移动到下一位,并从needle的头部重

2016-12-15 09:09:04 427

原创 [Leetcode] 27. Remove Element 解题报告

题目:Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constan

2016-12-14 23:07:29 378

原创 [Leetcode] 26. Remove Duplicates from Sorted Array 解题报告

题目:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in p

2016-12-14 22:57:25 368

原创 [Leetcode] 25. Reverse Nodes in k-Group 解题报告

题目:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain

2016-12-14 03:11:33 535

原创 [Leetcode] 24. Swap Nodes in Pairs 解题报告

题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant

2016-12-14 03:07:13 458

原创 [Leetcode] 23. Merge k Sorted Lists 解题报告

题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:        可以认为是Leetcode 21 Merge Two Sorted List的推广,其思路还是大同小异的,即每次从k个链表中找出头结点最小的那一个,加入到合

2016-12-13 23:29:04 364

原创 [Leetcode] 22. Generate Parentheses 解题报告

题目:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()",

2016-12-13 23:14:53 301

原创 [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.思路:        Easy级别的题目,没有特别的技巧。还是那句老话,在链表处理中如果能加一个

2016-12-13 23:00:14 269

原创 [Leetcode] 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

2016-12-13 05:08:03 312

原创 [Leetcode] 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

2016-12-13 04:51:37 288

原创 [Leetcode] 18. 4Sum 解题报告

题目:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The

2016-12-13 04:14:27 339

原创 [Leetcode] 17. Letter Combinations of a Phone Number 解题报告

题目:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input

2016-12-13 01:02:03 371

原创 [Leetcode] 16. 3Sum Closest 解题报告

题目:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would hav

2016-12-13 00:57:49 293

原创 [Leetcode] 15. 3Sum 解题报告

题目:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must no

2016-12-12 10:46:55 371

原创 [Leetcode] 14. Longest Common Prefix 解题报告

题目:Write a function to find the longest common prefix string amongst an array of strings.思路:        也是easy级别的题目。对这种难度的题目来说,优秀的程序员的功底就体现在如何把代码写的简洁优雅(自己原来写的代码将近30行,太low了)。代码:class Solution {

2016-12-12 10:38:17 353

原创 [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.思路:        可以看作是Leetcode 12的孪生题目,但是难度却比上一道题目低不少。通过上一道题目的分析可知,在该题目中只需要判断罗马数字

2016-12-12 05:44:35 308

原创 [Leetcode] 12. Integer to Roman 解题报告

题目:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路:首先熟悉一下罗马数字的的对应符号(以下内容参考小榕流光的博客,在此表示感谢):I (1)V(5)X(10) L(50)C(100)D(5

2016-12-12 05:17:35 306

原创 [Leetcode] 11. Container With Most Water 解题报告

题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and

2016-12-11 10:36:12 304

原创 [Leetcode] 10. Regular Expression Matching 解题报告

题目:Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire

2016-12-10 23:47:24 1060

原创 [Leetcode] 9. Palindrome Number 解题报告

题目:Determine whether an integer is a palindrome. Do this without extra space.思路:        题目不难,但仍然有三点需要特别注意:        1)如果是负数怎么办?假定如果是负数就返回false。        2)如果你想首先把整数转化为字符串,然后比较字符串是否是回文,那么需要考虑到此

2016-12-10 23:33:48 456

原创 [Leetcode] 8. String to Integer (atoi) 解题报告

题目:Implement atoi to convert a string to an integer.思路:       这是我见过的最简单的题目描述了。可是正因为简单,该题目的考点就在于我们如何实现算法使其能够鲁棒地处理各种情况。具体列举如下:       1)字符串开始前很可能有很多前导空格。前导空格应该被忽略。       2)字符串可能以正负符号开头,

2016-12-10 11:39:00 692

原创 [Leetcode] 7. Reverse Integer 解题报告

题目:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321思路:        这类特别简单的题目对大多数面试者而言,都能够有清晰的思路并进而写出相应的代码。那么区分度在哪里呢?就在于你对特殊情况的考虑和处理,以及你编写程序的严谨性。对于

2016-12-10 04:33:25 435

原创 计算几何学习笔记

计算几何的重要之处在于它是多门技术与学科的基础,例如图形学、CAD、GIS、路径规划等。这些技术的背后原理往往是基于计算几何的本质上。作为图形学和CAD领域的研究者和从业人员,个人十分推荐清华大学邓俊辉老师讲述的《计算几何》这门课程。所有对计算几何感兴趣的同学都可以通过学堂在线在线免费自主学习。本系列即为作者在学习过程中的学习笔记,一方面通过笔记加强作者对课程内容的理解;另一方面也通过博客分享这门

2016-12-09 05:08:35 1146

原创 [Leetcode] 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

2016-12-08 23:21:57 491

原创 [Leetcode] 5. Longest Palindromic Substring 解题报告

题目Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid answ

2016-12-08 11:58:28 510

原创 [Leetcode] 4. Median of Two Sorted Arrays 解题报告

题目:思路:代码:

2016-12-08 05:06:56 701

原创 [Leetcode] 3. Longest Substring without Repeating Characters 解题报告

题目: Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "...

2016-12-08 04:38:56 413

原创 [Leetcode] 2. Add Two Numbers 解题报告

题目: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it a...

2016-12-07 23:44:05 524

原创 [Leetcode] 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 num...

2016-12-07 11:15:29 599

转载 面向对象设计原则

对于面向对象软件系统的设计而言,在支持可维护性的同时,提高系统的可复用性是一个至关重要的问题,如何同时提高一个软件系统的可维护性和可复用性是面向对象设计需要解决的核心问题之一。在面向对象设计中,可维护性的复用是以设计原则为基础的。每一个原则都蕴含一些面向对象设计的思想,可以从不同的角度提升一个软件结构的设计水平。      面向对象设计原则为支持可维护性复用而诞生,这些原则蕴含

2016-12-07 11:13:02 429

空空如也

空空如也

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

TA关注的人

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