自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

ajiangfan的博客

希望能拥有一个思维捕捉器

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

原创 Python实现生成西瓜数据集的Excel文件

为了获得《机器学习》(周志华)中的完整西瓜数据集,这里通过Python使用xlwt模块自动生成数据集的Excel文件。实现代码如下:import xlwtdef createDataSet(): dataSet = [ # 1 ['1', '青绿', '蜷缩', '浊响', '清晰', '凹陷', '硬滑', 0.697, 0.460, '是'],...

2020-02-24 13:11:27 2020

翻译 如何识破“AI万金油”

本文的目的是让大家了解当前AI在各个领域的应用及发展情况,以此来识别网上那些打着AI的旗号进行各种不靠谱的评测和预测行为,即“AI万金油”骗术,防止大家被收智商税。一、为什么如今存在大量的”AI万金油“骗术?AI是一系列相关技术的涵盖性术语,其中有些技术已经取得杰出瞩目的进步,例如战胜人类顶尖围棋手的AlphaGo。不少公司利用公众的困惑来给他们正在出售的所有服务和产品打上“AI”的标签,另外...

2019-11-21 16:57:35 242

原创 Direct2D实现文字的描边和填充

一、实现思路通过继承IDWriteTextRenderer定义自己的文本渲染类并重写DrawGlyphRun方法,最终将该类实例作为 IDWriteTextLayout::Draw的参数传入进行文本的绘制。二、代码实现1、自定义文本渲染类class CustomTextRenderer : public IDWriteTextRenderer{protected: ULONG m_c...

2019-01-19 16:28:47 2065 1

原创 Direct2D实现文字镜像阴影

一、实现思路先绘制文字阴影部分,绘制阴影文本后应用3DTransform与高斯模糊特效,最后再正常绘制一次文本主体。二、实现代码 hr = m_pDWriteFactory->CreateTextFormat( sc_fontName, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FO...

2019-01-19 14:04:16 1256

原创 jack在64位win10下引起程序崩溃问题的解决方法

0、问题背景 自己的程序调用libjack64.dll启动时就发生异常崩溃,自己的开发环境是64位win10,在64位win7下测试可以正常运行。针对这个问题尝试了一些解决方案后,最终确定是使用的libjack64.dll和自己的应用程序库不兼容所导致的。1、尝试使用weak_libjack 使用weak_libjack的步骤如下: 0)把weak_libjack所有源文件拷到工程中 ...

2018-08-04 11:21:18 1180

原创 Tif文件与JPG文件之间的合并拆分实现(使用LibTIFF与OpenCV)

以下是使用LibTiff与OpenCV在win32控制台程序中实现tif文件与jpg文件之间的转换。将一个tif文件拆分为一或多张jpg图片:#include <afxwin.h>#include <afx.h>#include "tiffio.h"#include <iostream>#include <windef.h>#inc...

2018-03-23 17:15:28 4188 2

原创 Longest Common Prefix(最长相同前缀)

Write a function to find the longest common prefix string amongst an array of strings.(找出字符串数组中的最长相同前缀字符串)1.个人分析 思路一:采用BF法。首先取第一个字符串作为比较字符串,然后将该字符串的每个字符与其他字符串逐个进行比较,将所有相同的字符保存就是最终结果。2.个人解法string longe

2017-01-06 14:58:13 1600

原创 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.(给定含有n个元素的整型数组S,从数组S中找出所有的唯一三元组使得a+b+c=0成立)Not

2017-01-06 14:51:46 434

原创 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 (i, 0). Find two lin

2016-12-22 10:33:03 604

原创 Palindrome Number(回文数字)

Determine whether an integer is a palindrome. Do this without extra space.(判断一个整型数是否是回文,要求不能借用额外的空间)1.个人分析 题目中的额外空间应该是指空间复杂度为O(1),所有的负数不属于回文数。2.个人解法bool isPalindrome(int x) { if(x > INT_MAX || x

2016-12-18 20:49:42 815

原创 Reverse Integer(反转整型数)

Reverse digits of an integer.(反转一个整型数)Example1: x = 123, return 321 Example2: x = -123, return -3211.个人分析 思路一:整型数转字符串->反转字符串->字符串转整型 思路二:数学解法,不断地进行整除和取余运算。2.个人解法 (1)int reverse(int x) { int si

2016-12-12 16:58:18 1828

原创 ZigZag Conversion(“Z”形转换)

The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (字符串”PAYPALISHIRING”以给定的行数写成如下Z形模式) (you may want to display this pattern in a fixed font for better l

2016-12-12 16:53:25 2026

原创 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

2016-12-05 15:30:26 549

原创 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 as a linke

2016-12-03 14:26:15 679

原创 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

2016-12-02 18:12:49 1666 1

原创 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”]1.个人分析

2016-12-01 13:00:52 464

原创 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.(给定一个非负整数num,对每个在0<=i<=num范围

2016-11-30 10:54:52 1253

原创 Balanced Binary Tree(平衡二叉树)

Given a binary tree, determine if it is height-balanced.(给定一棵二叉树,判断该树的高度是否平衡)For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every

2016-11-29 18:51:27 698

原创 Number of Boomerangs(统计"boomerang"的数目)

Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tup

2016-11-28 14:50:48 407

原创 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 houses

2016-11-10 21:08:11 527

原创 Symmetric Tree(对称树)

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).(给定一棵二叉树,判断其是否对称)For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3

2016-11-09 16:44:44 372

原创 Binary Tree Level Order Traversal II(层次遍历二叉树II)

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 tr

2016-11-08 11:10:43 414

原创 Battleships in a Board(统计战舰数)

Given an 2D board, count how many different battleships are in it. The battleships are represented with ‘X’s, empty slots are represented with ‘.’s. You may assume the following rules: ● You receive

2016-11-07 16:39:39 270

原创 Arranging Coins(硬币排列)

You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.(给你n枚硬币来组成一个阶梯形,这个阶梯每第k行必须包含k枚硬币)Given n ,find the total number of full staircase

2016-11-03 21:36:00 1712

原创 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.(合并两个有序链表,并返回该新链表。新链表应该由最初的俩链表拼接而成)1.个人分析 与合并两个有序数组类似,只不过在这

2016-10-20 12:09:28 663

原创 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 ances

2016-10-17 12:10:06 292

原创 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 ugl

2016-10-15 13:16:45 632

原创 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?(n个台阶的楼梯,每次能够上1或2个台阶,有多少种不同到达顶部的走法?

2016-10-15 13:13:40 693

原创 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), desi

2016-10-15 13:10:05 470

原创 Number of 1 Bits(二进制中1的个数)

Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).(给定一个无符号整型数,实现一个函数返回该整数的二进制中1的个数)For example, the 32-bit integer ’11’ has bi

2016-10-12 11:25:00 516

原创 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.

2016-10-12 11:17:58 597

原创 Happy Number

Write an algorithm to determine if a number is “happy”.(判断一个数字是否是”happy”)A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum o

2016-10-12 11:12:44 256

原创 Power of Four

Given an integer (signed 32 bits), write a function to check whether it is a power of 4.(给定一个32位整型数,判断其是否是4的幂)1.个人分析 判断一个整型数是否是4的幂,必定是从2的幂中寻找符合条件的。1,2,4,8,16,32,64都是2的幂,其中1,4,16,64为4的幂,观察这些数的二进制位发现,它们

2016-10-07 12:35:15 349

原创 Power of Two

Given an integer, write a function to determine if it is a power of two.(给定一个整数,判断其是否是2的幂)1.个人分析 与判断是否是3的幂类似,普通解法就是不断地对输入的整数进行整除2,如果是2的幂则结果一定为1。2.个人解法bool isPowerOfTwo(int n) { if(n<1) re

2016-10-07 12:31:20 328

原创 Power of Three

Given an integer, write a function to determine if it is a power of three.(给定一个整数,判断其是否是3的幂)Follow up: Could you do it without using any loop / recursion?(能否不使用循环或递归实现?)1.个人分析 思路:最简单直观的做法是不断对3进行整除,如果

2016-10-07 12:26:27 341

原创 Intersection of Two Arrays(两数组的交叉元素)

Given two arrays, write a function to compute their intersection.(给定两个数组,计算它们的交叉元素)Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: ● Each element in the result must be unique.

2016-09-26 11:40:06 692

原创 Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.(给定一个非负整数num,重复加上它的所有数字直到结果只有一位数。)For example: Given num = 38, the process is like: 3 + 8 = 11, 1 +

2016-09-25 12:27:44 402

原创 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.1.个人分析 可以使用深度优先查找来得到二叉树的高度

2016-09-25 11:25:36 473

原创 Invert Binary Tree(反转二叉树)

Invert a binary tree.(反转一棵二叉树) 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 11.个人分析: 这道题其实在《剑指Offer》中看到过,只不过书中说的是镜像二叉树而已,但它们的本质是一样的,只要通过对根节点的左右孩子节点两两

2016-09-25 11:19:49 435

原创 Move Zeroes(移动零元素)

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.(给定一个数组,将数组中值为0的元素移动到所有非0元素的后面,而且非0元素之间保持原始的相对位置)For example, given

2016-09-24 11:49:56 621

空空如也

空空如也

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

TA关注的人

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