自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

不积跬步无以至千里

不积小流无以成江海

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

原创 C#中调试和错误的处理

正常模式下的调试1,在vs中使用Console.Write(或者WriteLine)方法向控制台输出变量的值,通过这种形式来观察变量的值是否符合预期。2,在Unity中可以使用Debug.Log(“”) Debug.LogError(“”) Debug.LogWarn(“”),想Unity的Console窗口输出信息,方便进行调试错误。中断模式下的调试通过断点的设置,暂停程序的...

2018-03-31 21:42:19 3569

原创 231. Power of Two

1,题目要求 Given an integer, write a function to determine if it is a power of two. 即判断一个数是不是2的幂次。2,跟前面求是否是3的幂次类似,可以直接套用那两种思想。 同时,可以用一种新的方式,适用于2的幂次的方法: 首先,2的幂次的二进制形式都是“100..0”的形式,因此,如果n是2的幂次,则其与n-1进...

2018-03-31 14:46:50 243

原创 326. Power of Three

1,题目要求 Given an integer, write a function to determine if it is a power of three. 即给定一个数字,判断其是否是3的幂次。返回true false。不要使用循环或者迭代。2,题目思路 无法使用循环或者迭代,则必须要利用幂次的数学原理来进行求解。 参考后,一共两种思路办法,而且这两种方法应该都具有通用性。...

2018-03-30 20:53:31 267

原创 21. Merge Two Sorted Lists

1,题目要求 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. 也就是将两个单链表进行融合,变成一个单链表。2,题目思路 对于这种类型,主要有两种思路:...

2018-03-29 19:56:02 188

原创 405. Convert a Number to Hexadecimal

1,题目要求 将十进制的数字转换为十六进制的形式,并且要可以对负数进行转换。 2,题目思路 如果仅仅是对十进制的数字转换为十六进制,其实还是不难的,关键在于对负数应该如何去处理。 在这里面,负数是转化为补码的形式来进行运算的。 在参考的算法后,得到了如下的实现思路: 首先,定义一个字符串,用来获取相应十进制->十六进制的相关字符串。当然,也可以用字符相加减来获得,不过还需要将...

2018-03-28 13:38:44 321

原创 257. Binary Tree Paths

1,题目要求 Given a binary tree, return all root-to-leaf paths. 2,题目思路 依然是利用递归的方法,对整棵树进行遍历,每当找到左右孩子节点都为空的节点时,便将这一条路径得到字符串加入到vector中;否则,就对左右子树分别进行路径的查询。 树的递归最好写一个递归函数来进行操作。3,程序源码/** * Definitio...

2018-03-27 14:16:03 140

原创 594. Longest Harmonious Subsequence

1,题目要求 We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1.Now, given an integer array, you need to find the length of its lon...

2018-03-26 13:49:20 139

原创 70. Climbing Stairs

1,题目要求 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? 对于n阶的楼梯,一次可以爬一阶或者两阶楼梯,...

2018-03-25 12:52:21 215

原创 720. Longest Word in Dictionary

1,题目要求 Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If there is more than one po...

2018-03-24 15:33:58 225

原创 对于未来的考量

既然已经下定决心要走游戏开发的路线,就不能在进行动摇了。 跟王哥交流了一番,看了几位直接获得提前面试资格的牛人的简历,发现个人的项目经历完全是可以进行自我实现的。比如一位自己实现了简单的linux内核,就是完美的闪光点。在游戏服务器开发的领域,就很需要有这方面才能的人。对于游戏开发,自己的作品肯定是必不可少的。只是在CSDN上写博客,自然是不够的。在GitHub上上传自己的项目记录,在以后的...

2018-03-23 21:25:18 252

原创 202. Happy Number

1,题目要求 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 s...

2018-03-23 19:45:26 223

原创 415. Add Strings

1,题目要求 Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is < 5100. Both num1 and num2 contains only d...

2018-03-22 14:46:19 143

原创 671. Second Minimum Node In a Binary Tree

1,题目要求 Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this n...

2018-03-21 10:50:25 160

原创 747. Largest Number At Least Twice of Others

1,题目要求 In a given integer array nums, there is always exactly one largest element.Find whether the largest element in the array is at least twice as much as every other number in the array.If it ...

2018-03-20 10:15:30 324

原创 107. Binary Tree Level Order Traversal II

1,题目要求 Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For example: Given binary tree [3,9,20,null,...

2018-03-19 14:33:25 136

原创 674. Longest Continuous Increasing Subsequence

1,题目要求 Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). 找到一个连续的最长递增子序列。 2,题目思路 还是利用了动态规划的基本思想。动态去依次寻找最长的递增子序列。设置一个count变量来记录每次满足递增条件的...

2018-03-18 11:01:28 170

原创 121. Best Time to Buy and Sell Stock

1,题目要求 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 s...

2018-03-17 14:30:35 148

原创 746. Min Cost Climbing Stairs

1,题目要求 On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the...

2018-03-16 20:30:46 141

原创 541. Reverse String II

1,题目要求 Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all...

2018-03-15 22:42:27 125

原创 504. Base 7

1,题目要求 将一个数转化为7进制的数 注意转化为一个字符串。 2,题目思路 对于负数,要进行记录并将其转化为正数再进行操作。 跟在十进制时获得每一位的数字时的方法相同,只不过将10变为7即可。 3,程序源码class Solution {public: string convertToBase7(int num) { if(num < 0)...

2018-03-14 15:32:28 190

原创 784. Letter Case Permutation

1,题目要求 一种对字母的大小写形式的一种遍历,对数字不做处理。 2,题目思路 题目看起来不难,可是仔细思考发现一定要用到递归思想,否则穷举法根本不能实现。 因此,设计递归形式就非常关键了。 递归在设计时,个人觉得重要的是返回出口在哪里,以及每次结果的产生的记录。 因此,主题函数如下: 3,程序源码class Solution {public: vector&l...

2018-03-13 14:51:11 246

原创 796. Rotate String

1,题目要求 We are given two strings, A and B.A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = ‘abcde’, then it will be ‘bcdea’ a...

2018-03-12 16:11:36 740

原创 108. Convert Sorted Array to Binary Search Tree

1,题目要求 给定一个升序排列的数组,将其转化为一个高度平衡的二叉搜索树。 Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined ...

2018-03-11 19:49:50 129

原创 551. Student Attendance Record I

1,题目要求 You are given a string representing an attendance record for a student. The record only contains the following three characters: ‘A’ : Absent. ‘L’ : Late. ‘P’ : Present. A student could be...

2018-03-10 00:22:21 122

原创 350. Intersection of Two Arrays II

1,题目要求 Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. 求两个数组的交集。 2,题目思路 利用Hash表即可达到条件。需要注意的是,定义Hash表用到一个特殊的方...

2018-03-09 13:48:58 126

原创 744. Find Smallest Letter Greater Than Target

1,题目要求 Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list that is larger than the given target.Lett...

2018-03-08 18:44:27 257

原创 628. Maximum Product of Three Numbers

1,题目要求 Given an integer array, find three numbers whose product is maximum and output the maximum product. 需要注意的是,给定的数字中也有负数的存在,因此需要单独进行判断。 2,题目思路: 题目的要求是求出三个数的最大的成乘积,因此想到的办法便是对其进行排序,然后直接取最大的三个数...

2018-03-07 13:38:04 178

原创 401. Binary Watch

1,题目要求 A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significant...

2018-03-06 15:08:36 232

原创 268. Missing Number

1,题目要求: Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array. 也就是给n个数字,判断少了哪个数字。要求用线性的时间来进行探查,并利用有限的额外空间。 2,题目思路: 一开始想直接利用vector的排序函...

2018-03-05 19:28:07 141

原创 543. Diameter of Binary Tree

1,题目要求 Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may ...

2018-03-05 11:58:03 241

原创 409. Longest Palindrome

1,题目要求: Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is ...

2018-03-04 14:21:51 164

原创 LeetCode的语言使用

看来以后不能再用python来写算法的题目了。用python竟然是一种取巧的办法,以后还是用C++来写吧。python里面有很多内置的库,这也就导致掩盖了很多复杂的算法的特性。虽然在写代码的时候很简单,但是对个人的提高其实不大。...

2018-03-04 09:27:34 5259

原创 LC-Image Smoother

import copyclass Solution(object): def imageSmoother(self, M): """ :type M: List[List[int]] :rtype: List[List[int]] """ len_x = len(M) len_y = len...

2018-03-03 18:44:36 201

原创 LC-Number of Boomerangs

class Solution(object): def numberOfBoomerangs(self, points): """ :type points: List[List[int]] :rtype: int """ res = 0 for p in points: ...

2018-03-02 11:19:07 150

原创 LC-Minimum Index Sum of Two Lists

方法1:class Solution(object): def findRestaurant(self, list1, list2): """ :type list1: List[str] :type list2: List[str] :rtype: List[str] """ common...

2018-03-01 16:56:22 217

空空如也

空空如也

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

TA关注的人

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