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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ |
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
// 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> |
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 "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) | |
{ |
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
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: |
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
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; | |
} |
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
Program: | |
class Program | |
{ | |
string myString; | |
private Program() | |
{ | |
myString = "foo"; | |
} |
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
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。 | |
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。 | |
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。 | |
class Program | |
{ | |
public static int RemoveMultipleSpaces(char[] baseStr) | |
{ | |
if (baseStr == null) | |
{ | |
throw new ArgumentNullException("baseStr"); |