- 博客(7)
- 问答 (2)
- 收藏
- 关注
原创 Introduction of Algorithm - Divide and Conquer(分治法)
Divide and Conquer(分治法):1. Divide: the problem(instance) into one or more subproblems.(把问题分解成一个或多个子问题)2. Conquer: each subproblem recursively.(递归的解决每个子问题)3. Combine: solutions.Ex1: Mer
2016-05-29 15:50:23 724
原创 leetcode No26. Remove Duplicates from Sorted Array
Question: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 place...
2016-05-16 21:12:27 553
原创 leetcode No258. Add Digits
Question:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. S
2016-05-16 20:52:04 881
原创 leetcode No292. Nim Game
Question:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last st
2016-05-16 20:46:38 819
原创 leetcode No344.Reverse String Note
Question:Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".算法:(1)复制一个字符串 (2)逆序给原来的字符串class Solution {public:
2016-05-16 20:40:57 723
原创 leetcode No189.Rotate Array
PS:介绍两种算法及C/C++代码Question: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].Solution:
2016-05-14 19:49:40 587
原创 C语言中的复制函数(strcpy和memcpy)
PS:初学算法,开始刷leetcode,Rotate array的预备知识(写的算法Time Limit Exceed)于是百度高效算法,本篇讲述预备知识。1、strcpy和strncpy函数这个不陌生,大一学C语言讲过,其一般形式为strcpy(字符数组1,字符串2)作用是将字符串2复制到字符数组1中去。EX:strncpy(str1,str2,2);作用是将st
2016-05-14 17:15:27 83783 5
空空如也
hexo 搭建博客-hexo new出错
2017-03-16
stable_partition怎么实现的
2016-10-08
TA创建的收藏夹 TA关注的收藏夹
TA关注的人