04 2017 档案
摘要:Total Accepted: 11103Total Submissions: 17987Difficulty: EasyContributors:joshpowellGiven a string, you need to reverse the order of characters in each word within a sentence while still preserving wh...
阅读全文
摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as poss...
阅读全文
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ c...
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Algorithm { class MyListNode { public T Key { get; set; } public MyListNode N...
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings.public class Solution { public string LongestCommonPrefix(string[] strs) { StringBuilder result = new StringBu...
阅读全文
摘要:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".public class Solution { public string AddBinary(string a, string b) { int length = Math.Ma...
阅读全文
摘要:// #define USING_HASH_SET// ==++==// // Copyright (c) Microsoft Corporation. All rights reserved.// // ==--==/*============================================================**** Class: SortedSet****...
阅读全文
摘要:/*** 广度优先遍历* **/public void BreadthFirstTreeWalk(BSTreeNode root, Action> func) { if (root == null) { return; } List> processQueue = new List>(); processQueue.Add(root); BSTreeNode current; while (pr...
阅读全文
摘要:/*** 非递归 中序遍历* **/public void InOrderTreeWalk(BSTreeNode root, Action> func) { if (root == null) { return; } Stack> stack = new Stack>((int)(2 * Math.Log(Count + 1))); BSTreeNode current = root; whil...
阅读全文
摘要:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.p...
阅读全文
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2, then o...
阅读全文
摘要:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5题意:移除链表中指定val的元素注意:考虑删除节点在尾部,以及连续删除两...
阅读全文
摘要: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 but ...
阅读全文
摘要:We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it is a perfect ...
阅读全文
摘要:博客设置 -> 页面定制CSS代码填入以下样式表/*Original style from softwaremaniacs.org (c) Ivan Sagalaev */.hljs { display: block; padding: 0.5em; background: #F0F0F0;}.hljs,.hljs-subst,.hljs-tag .hljs-title,.lisp .hljs...
阅读全文
摘要:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断一个链表是否为回文串思路:1.找到中间点,2.反转后半部分链表,3.判断前半部分与后半部分是否相同/** * Definition for singly-linked ...
阅读全文

浙公网安备 33010602011771号