- 博客(81)
- 资源 (9)
- 问答 (1)
- 收藏
- 关注
原创 ASP.NET MVC中使用JS实现不对称加密密码传输
ASP.NET MVC中登录页面中点击登录后,用户名、密码将被明文传输到Controller中,使用Fiddler等工具可以轻松截获并获取密码, 这是不安全的。 使用对称加密,如AES,密钥将被暴露前端代码,也是不安全的。使用不对称加密能够较好解决这个问题。本文以RSA不对称加密的形式,在JS端通过公钥对密码进行加密,将密文传输到后端后通过密钥进行解密。
2017-07-14 05:25:44
4700
2
原创 ASP.NET HttpModule的使用说明
摘要:HttpModule可以用于全局身份验证、url重写、异常处理等场景。本文以身份验证为场景,介绍HttpModule的使用。 包括在IIS7.0及以后版本如何配置web.config文件才能使得HttpModule生效;
2017-05-18 02:17:03
764
原创 什么是CSRF攻击,如何在ASP.NET MVC网站中阻止这种攻击?
本文介绍什么是CSRF攻击,及如何在ASP.NET MVC网站应用程序中阻止CSRF攻击。
2017-05-12 02:28:13
1730
原创 使用存储过程和反射获取从多个数据表所需信息
本文介绍如何使用存储过程和读取范式化数据库获取所需信息的技术,使用到的技术有:存储过程,反射。 此技巧适用于与多处连表(大量JOIN)的场景。 对于单表操作,建议使用UnitOfWork+Repository的设计模式的EF操作方法,该方法并非本文描述重点。
2017-03-16 10:40:13
824
原创 算法-- 2分查找 Binary Search
思路:当数据量很大适宜采用该方法。采用二分法查找时,数据需是排好序的。主要思想是:(设查找的数组区间为array[low, high])(1)确定该区间的中间位置K(2)将查找的值T与array[k]比较。若相等,查找成功返回此位置;否则确定新的查找区域,继续二分查找。区域确定如下:a.array[k]>T 由数组的有序性可知array[k,k+1,……,high]>T
2017-02-26 01:41:02
334
原创 算法--动态规划篇
Dynamic Programming(动态规划)简介:1)需要辅助空间,记录子问题解决结果。2)明确各个子问题之间的关系,避免重复计算3)通常对数组和字符串的高难度面试题有效。与分治算法比较类似,但不同的是分治算法把原问题划归为几个相互独立的子问题,从而一一解决,而DP则是针对子问题有重叠的情况的一种解决方案。思路:利用recursive method
2017-02-22 08:56:01
414
原创 int MaxWindowTotal(int[] values, int windowSize)
原题:MaxWindowTotal will take an array of integers and a windowSize, and return the maximum total of any consecutive sequence of integers of length windowSize.For example, given (array = [5, 12,
2017-02-21 04:40:28
541
原创 JS 日期格式转换
后端DateTime类型JSON序列化以后,传到前端变成这样,怎么办? "/Date(1485493200000)/"格式分析:这其实是1970 年 1 月 1 日至今的毫秒数;1391141532000/1000/60/60/24/365=44.11年,44+1970=2014年,按这种方法可以得出年月日时分秒和毫秒。这种格式是一种可行的表示形式但不是普通人可以看懂的友好格式,怎
2017-01-21 05:52:09
559
原创 算法--全排列、全子集、DFS\BFS问题
排列组合子集合 subset(medium)输入一个含有不同数字的序列,输出所有可能的集合(含空集)。要求1 集合里元素有序排列;2 输出结果不含有重复集合;举例:输入{1,2,3], 输出{},{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}原题:https://leetcode.com/problems/subsets/思路图:Amor
2017-01-18 11:18:53
2693
1
原创 算法-两根指针类问题
1 有序数组去重给出有序数组,就地移除重复元素,保证无重复,并返回新数组长度;举例:已知:A=[1,1,2,3,3] 输出长度3, A=[1,2,3]思路图: public static int RemoveDuplicate(int[] arr) { if (arr == null || arr.Length ==
2017-01-16 07:06:29
685
原创 字符串String 算法题
1 字符判重 isUniqueChar(string str)要求:输入字符串,判断该串是否不含有重复字符需要确认问题:encoding是UTF-8还是ASCII码?思路:使用hashtable记录字符出现情况;如果已经存在,就说明有重复;如果是ASCII,使用256位数组即可;UTF8(万国码)编码的解释:http://baike.baidu.com/item/UTF
2017-01-06 09:03:13
733
原创 17. Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st
2016-10-23 00:33:08
327
原创 242. Valid Anagram
原题链接:https://leetcode.com/problems/valid-anagram/Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat
2016-10-19 09:56:00
286
原创 206. Reverse Linked List
原题:https://leetcode.com/problems/reverse-linked-list/内容:Reverse a singly linked list.A linked list can be reversed either iteratively or recursively. Could you implement both?总思路图:
2016-10-19 04:46:46
334
原创 204. Count Primes
题目:https://leetcode.com/problems/count-primes/题目要求:输出比一个非负数字N小的prime的个数;质数,百度百科:http://baike.baidu.com/view/10626.htm素数: 是只有两个正因子(1和自己)的自然数;最小的素数是2;合数: 比1大但不是素数的数称之为合数;0和1不是素数也不是合数;IsPrime
2016-10-17 06:18:48
239
原创 Leetcode 102 Binary Tree Level Order Traversal
题目:https://leetcode.com/problems/binary-tree-level-order-traversal/九章算法答案:http://www.jiuzhang.com/solutions/binary-tree-level-order-traversal/思路:Queue使用时要尽量避免Collection的add()和remove()方
2016-10-15 07:48:28
267
原创 Leetcode 155 Min Stack
链接:https://leetcode.com/problems/min-stack/题目要求:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stac
2016-10-14 10:39:38
352
原创 Leetcode Longest Substring Without Repeating Characters
原题:https://leetcode.com/problems/longest-substring-without-repeating-characters/Given a string, find the length of the longest substring without repeating characters.Examples:Given "abca
2016-10-13 23:59:26
267
原创 Leetcode 21. Merge Two Sorted Lists
原题链接:https://leetcode.com/problems/merge-two-sorted-lists/思路:0 处理边界条件1 两个输入链表可能为空,采用dummy节点,使得dummy.next指向新链表的第一个节点。2 初始化时,使用两个指针指向两个链表的表头,两个指针同时不为空时,取较小的节点放入新链表的尾部。3 然后把链表
2016-10-13 10:16:05
264
原创 Leetcode 20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid bu
2016-10-12 06:28:12
225
原创 Leetcode 15 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.Note: The solution set must not contain
2016-10-12 05:45:18
303
原创 Leetcode2 Add Two Numbers
原题链接:https://leetcode.com/problems/add-two-numbers/给出两个整数,每个整数由一个链表表示。其中链表每个节点保存数的数位,这些数位反序存在链表中,即高位在最后,低位在最前面。返回一个链表代表这两个数之和。举例,如图:思路:由于反序存储在链表中,可以从表头开始顺序相加;两个链表长度不同,如何相加链表而没有剩余
2016-10-10 23:47:29
243
原创 Leetcode 236. Lowest Common Ancestor of a Binary Tree
原题:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/题目大意:已知一个BT,找到BST中的节点p+q的最小公共祖先;例子: _______3______ / \ ___5__ ___1__ /
2016-10-10 04:02:54
320
原创 Leetcode 235. Lowest Common Ancestor of a Binary Search Tree
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/题目大意:已知一个BST,找到BST中的节点p+q的最小公共祖先;思路:递归1 boundary conditions: tree, p, q任意为null, 返回null2 如果p.va, q.val均小于root.val ->
2016-10-10 03:24:30
255
原创 CC150 4.6 Successor
Successor: write an algorithm to find the "next" node(i.e. in-order successor) of a given node in a binary search tree. you may assume that each node has a link to its parent已知BST中的一个node, 写算法找到下一个节
2016-10-10 01:38:46
286
原创 Leetcode 98. Validate Binary Search Tree
https://leetcode.com/problems/validate-binary-search-tree/Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a
2016-10-09 11:37:02
300
原创 CC150 4.4 Check Balanced; Leetcode 110. Balanced Binary Tree
Leetcode link: https://leetcode.com/problems/balanced-binary-tree/Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined asa bin
2016-10-09 09:38:55
541
原创 CC150 Mimimal Tree 生成最小高度树
4.2 Minmal TreeGiven a sorted(increasing order ) array with unique integer elements write an algorithm to create a binary search tree with an algorithm to create a vinary search tree with minimal he
2016-10-09 06:39:36
747
原创 CC150 3.4 Queue via Stacks
queue via stacks: implement a my Queue class which implements a queue using 2 stacks.通过2个stack实现 MyQueue类public class MyQueue { Stack stackNew, stackOld; public MyQueue
2016-10-08 04:59:39
462
原创 CC150 3.1 Three in one: describe how you could use a single array to implement 3 stacks.
fixed Division思路:1 把数组等分;2 允许stack在其中增长;stack0 [0,n/3)stack1 [n/3,2n/3)stack2 [2n/3,n)class FixedMultiStack { int numberOfStacks = 3; int stackCapacity;
2016-10-06 05:08:48
472
原创 Leetcode 10. Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cov
2016-10-06 04:05:40
249
原创 "IQueryable and IEnumerable"区别
Answer: "IQueryable" 有延时加载机制;而且从数据库中筛选数据;IEnumerable 从数据库中选择所有的数据,在内存中做筛选var 默认等效于IEnumerable C#范例代码:class Program { static void Main(string[] args) { Lis
2016-10-04 07:21:34
334
原创 Leetcode 160. Intersection of Two Linked Lists/CC150 2.7
https://leetcode.com/problems/intersection-of-two-linked-lists/Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two lin
2016-10-04 03:34:14
341
原创 CC150 2.6/Leetcode Palindrome LinkedList
判断 Linked List是否属于回文思路:迭代法+快慢指针快指针是慢指针速度的两倍;1 while循环,fast到tail,slow只到一半;2 slow内容均迭代放入stack3 如果linkedlist元素个数是奇数(fast!=null), slow需要前移1 位4 然后对比stack 的顶元素与slow指针指向的内容; 不等-> 返回false; 相等
2016-10-03 22:45:25
375
原创 Last K elements in LinkedList(CC150 2.2)
https://www.hackerrank.com/contests/infinitum15/challenges/k-element-sequences实现一个算法,发现singly linked list中倒数第k个元素;思路1 如果已知linked list 长度length, kth个元素为(length-k); 通过这种方式可以找到这个元素;这种解法明显不是interv
2016-09-30 23:42:43
660
原创 CC150 2.8&&Linked List Cycle dection 判断循环LinkedList
https://leetcode.com/problems/linked-list-cycle/《进军硅谷》类似题目:环的长度题目:给出一个单向链表头指针,如果有环,判断环的长度,否则返回0;思路:1 判断链表是否有环。 使用快慢指针,如果快指针已经到尾部,而且他们没有相遇,则无环;如果他们相遇,则有环2 上图为例:慢指针:9->8->7->1;
2016-09-30 13:39:22
398
原创 CC150 1.7 ROTATE MATRIX 旋转矩阵
1.7 Rotate MatrixGiven an image represented by an N*N matrix, where each pixel(像素) in the image is 4 bytes, write a method to rotate te image by 90 degrees. Can you do this in place?思路1:1 分层
2016-09-30 00:28:28
494
原创 HackRank Stacks: Balanced Brackets;/Leetcode valid-parentheses; 括号匹配
A bracket is considered to be any one of the following characters: (, ), {, }, [, or ].Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs
2016-09-29 23:05:21
825
Jquery Ajax 跨域调用asmx类型 WebService范例代码
2016-05-08
支持取消操作和暂停操作的Backgroundworker示例
2014-11-08
SqlBulkCopy代码
2014-11-07
获取目标机器MAC地址、公网IP、所在城市信息
2014-08-19
RegexTextBox 正则 textBox 控件 可复用
2011-11-30
已知经纬度,球地球上两点之间距离(考虑地球曲率)
2011-09-16
WebService(axmx)如何实现完美跨平台?
2015-05-09
TA创建的收藏夹 TA关注的收藏夹
TA关注的人