Skip to content

Instantly share code, notes, and snippets.

View Ninputer's full-sized avatar

Fan Shi Ninputer

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
@Ninputer
Ninputer / List.cs
Created November 2, 2012 11:28 — forked from JeffreyZhao/List.cs
// As we all know, the generic List<T> class in .NET doesn't
// have a RemoveMultiple method. Could you implement it for me?
// Say the elements are kept in the _items field, which is an
// array of type T. Also, use _count to keep the current number
// of elements.
// PS: You can compare two items with "==" operator.
namespace System.Collections.Generic
{
public class List<T>
@Ninputer
Ninputer / split_by_blank.c
Created September 15, 2012 17:41
split by blank implementation
#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
//return value: the pointer used to free the allocated buffer
char* split_by_blank(char * input, char **& output, size_t& item_count, size_t max_item_count)
{
if (max_item_count <= 0)
{
def quicksel(l,k):
if len(l) <k:
raise ValueError
else:
pivot=l.pop()
lg=filter(lambda x:x>pivot,l)
ll=filter(lambda x:x<=pivot,l)
if len(lg)>=k:
return quicksel(lg,k)
elif len(lg)+1==k:
@Ninputer
Ninputer / List 递归
Created July 30, 2012 10:20 — forked from anonymous/List 递归
递归创建List并填充值
List<string> CreateInstanVar(int time_in_level1)
{
List<string> result = new List<string>();
for (int i = 0; i < time_in_level1; i++)
{
result.Add(String.Empty);
}
return result;
}
@Ninputer
Ninputer / gist:2967888
Created June 21, 2012 19:12 — forked from anonymous/gist:2967637
.NET 4.5 Disassembly
Program:
class Program
{
string myString;
private Program()
{
myString = "foo";
}
@Ninputer
Ninputer / RemoveMultipleSpaces.cs
Created March 28, 2012 15:23
模拟微面试之去空格
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。
class Program
{
public static int RemoveMultipleSpaces(char[] baseStr)
{
if (baseStr == null)
{
throw new ArgumentNullException("baseStr");