0%

## Reverse Integer

Posted on 2015-03-13 Edited on 2020-01-12 In leetcode Views: Disqus:

### Reverse Integer

#### Reverse digits of an integer.

Example1: x = 123, return 321
Example2: x = -123, return -321

Read more »

## Reverse Bits

Posted on 2015-03-11 Edited on 2020-01-12 In leetcode Views: Disqus:

### Reverse Bits

#### Reverse bits of a given 32 bits unsigned integer.

For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110000010100101000000).

Read more »

## Number of 1 Bits

Posted on 2015-03-11 Edited on 2020-01-12 In leetcode Views: Disqus:

### 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 `00000000000000000000000000001011`, so the function should return 3.

Read more »

## pcre-intro-and-a-simple-package

Posted on 2015-01-16 Edited on 2020-01-12 In C++ Views: Disqus:

### Pcre

> Perl Compatible Regular Expressions (PCRE) is a regular
> expression C library inspired by the regular expression
> capabilities in the Perl programming language, written
> by Philip Hazel, starting in summer 1997.

因为最近工作内容的一部分需要做字符串的识别处理，所以就顺便用上了之前在PHP中用过的正则，在C/C++中本身不包含正则库，这里使用的pcre，对MFC开发，在这里提供了静态链接库，在引入lib跟.h文件后即可使用。

Read more »

## two sum

Posted on 2015-01-14 Edited on 2020-01-12 In leetcode Views: Disqus:

### problem

Given an array of integers, find two numbers such that they add up to a specific target number.

The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.

Read more »

## Path Sum

Posted on 2015-01-04 Edited on 2020-01-12 In leetcode Views: Disqus:

### problem

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.

Read more »

## Clone Graph Part I

Posted on 2014-12-30 Edited on 2020-01-12 In leetcode Views: Disqus:

### problem

    1
    2
    3
    4
    5
    6
    Clone a graph. Input is a Node pointer. Return the Node pointer of the cloned graph.

    A graph is defined below:
    struct Node {
    vector neighbors;
    }

Read more »

## MFC 模态对话框

Posted on 2014-12-24 Edited on 2020-01-12 In C++ Views: Disqus:

    1
    2
    3
    4
    5
    6
    7
    void CTestDialog::OnBnClickedOk()
    {
    	CString m_SrcTest;
    	int nIndex = m_CbTest.GetCurSel();
    	m_CbTest.GetLBText(nIndex, m_SrcTest);
    	OnOK();
    }

模态对话框弹出确定后，在弹出对话框时新建的类及其变量会存在，但是对于其中的控件
对象无法调用函数，即如果要在主对话框中获得弹出对话框的Combo box选中值的话，需
要在弹出 对话框的确定函数内将其值取出，赋值给弹出对话框的公有变量，这样就可以
在主对话框类得到值。

## C++ 指针使用中的一个小问题

Posted on 2014-12-23 Edited on 2020-01-12 In C++ Views: Disqus:

#### 在工作中碰到的一点C++指针上的一点小问题

在C++中，应该是从C语言就开始了，除了void型指针之外都是需要有分配对应的内存才可以使用，同时malloc与free成对使用，new与delete成对使用，否则造成内存泄漏。