C: 1, 3, 6
C++: 1, 3, 4, 6
Cobol:
Fortran:
Java: 1, 3, 4, 6
Lisp:
ML:
Perl:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 树 | |
## 树状数组(Binery Index Tree) | |
### 简介 | |
其初衷是解决数据压缩里的累积频率(Cumulative Frequency)的计算问题,现多用于高效计算数列的前缀和, 区间和。 | |
它可以以 {\displaystyle O(\log n)} O(\log n)的时间得到任意前缀和 {\displaystyle \sum _{i=1}^{j}a[i],1<=j<=N} {\displaystyle \sum _{i=1}^{j}a[i],1<=j<=N},并同时支持在 {\displaystyle O(\log n)} O(\log n)时间内支持动态单点值的修改。空间复杂度 {\displaystyle O(n)} O(n)。 | |
### 基本操作 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
public class Solution | |
{ | |
public int[] TwoSum(int[] nums, int target) | |
{ | |
int pair; | |
Hashtable ht = new Hashtable(); | |
for (int i = 0; i < nums.Length; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ListNode { | |
public int val; | |
public ListNode next; | |
public ListNode(int x) { val = x; } | |
} | |
public class Solution | |
{ | |
public ListNode AddTwoNumbers(ListNode l1, ListNode l2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution | |
{ | |
public int LengthOfLongestSubstring(string s) | |
{ | |
int subLength = 0; | |
int r = 0; | |
int repetitionIndex; | |
int start = 0; | |
for (int i = 0; i < s.Length; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution | |
{ | |
public string LongestPalindrome(string s) | |
{ | |
bool isPalindromic = false; | |
if(s.Length==0){ | |
return ""; | |
} | |
for (int i = s.Length; i > 0; i--) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
函数(参数:节点) | |
{ | |
定义:一个队列 | |
初始化:节点入队 | |
搜索过程: | |
循环(当队列为不为空时继续) | |
{ | |
1. 队首出队 | |
2. 此处插入验证(可在此处退出)条件 | |
3. 将出队节点的子节点加入队列 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
函数(参数:节点) | |
{ | |
定义:一个栈 | |
初始化:节点入栈 | |
搜索过程: | |
循环(当栈为不为空时继续) | |
{ | |
1. 栈顶出栈 | |
2. 此处插入验证(可在此处退出)条件 | |
3. 将出栈节点的子节点加入栈 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void swap(int arr[], int i, int j) | |
{ | |
int temp = arr[i]; | |
arr[i] = arr[j]; | |
arr[j] = temp; | |
} | |
//bubble | |
void f1(int arr[], int length) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <tchar.h> | |
int _tmain(int argc, TCHAR *argv[], char *envp[]) | |
{ | |
} |
OlderNewer