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... 阅读全文
posted @ 2017-04-28 00:22 xiejunzhao 阅读(172) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-04-24 23:49 xiejunzhao 阅读(115) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-04-19 00:07 xiejunzhao 阅读(168) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-04-17 23:44 xiejunzhao 阅读(313) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-04-16 00:12 xiejunzhao 阅读(177) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-04-15 22:19 xiejunzhao 阅读(214) 评论(0) 推荐(0)
摘要:// #define USING_HASH_SET// ==++==// // Copyright (c) Microsoft Corporation. All rights reserved.// // ==--==/*============================================================**** Class: SortedSet****... 阅读全文
posted @ 2017-04-12 23:37 xiejunzhao 阅读(351) 评论(0) 推荐(0)
摘要:/*** 广度优先遍历* **/public void BreadthFirstTreeWalk(BSTreeNode root, Action> func) { if (root == null) { return; } List> processQueue = new List>(); processQueue.Add(root); BSTreeNode current; while (pr... 阅读全文
posted @ 2017-04-11 23:52 xiejunzhao 阅读(589) 评论(0) 推荐(0)
摘要:/*** 非递归 中序遍历* **/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... 阅读全文
posted @ 2017-04-11 23:50 xiejunzhao 阅读(297) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-04-11 22:55 xiejunzhao 阅读(200) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-04-08 23:29 xiejunzhao 阅读(127) 评论(0) 推荐(0)
摘要: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的元素注意:考虑删除节点在尾部,以及连续删除两... 阅读全文
posted @ 2017-04-05 00:12 xiejunzhao 阅读(208) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2017-04-04 11:01 xiejunzhao 阅读(168) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2017-04-04 10:08 xiejunzhao 阅读(199) 评论(0) 推荐(0)
摘要:博客设置 -> 页面定制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... 阅读全文
posted @ 2017-04-02 00:01 xiejunzhao 阅读(388) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2017-04-01 23:30 xiejunzhao 阅读(162) 评论(0) 推荐(0)