伪程序员的世界

Debug myself and debug the world!


  • 首页

  • 归档

  • 分类

  • 标签

  • 搜索

网易2017春招笔试——调整队形

发表于 2018-01-23 | 分类于 算法 , 2017网易春招笔试
字数统计: 1.2k | 阅读时长≈ 0:01

调整队形

题目

在幼儿园有n个小朋友排列为一个队伍,从左到右一个挨着一个编号为(0~n-1)。其中有一些是男生,有一些是女生,男生用’B’表示,女生用’G’表示。小朋友们都很顽皮,当一个男生挨着的是女生的时候就会发生矛盾。作为幼儿园的老师,你需要让男生挨着女生或者女生挨着男生的情况最少。你只能在原队形上进行调整,每次调整只能让相邻的两个小朋友交换位置,现在需要尽快完成队伍调整,你需要计算出最少需要调整多少次可以让上述情况最少。例如:

GGBBG -> GGBGB -> GGGBB
这样就使之前的两处男女相邻变为一处相邻,需要调整队形2次

阅读全文 »

网易2017春招笔试——赶去公司

发表于 2018-01-23 | 分类于 算法 , 2017网易春招笔试
字数统计: 1.4k | 阅读时长≈ 0:01

赶去公司

题目

终于到周末啦!小易走在市区的街道上准备找朋友聚会,突然服务器发来警报,小易需要立即回公司修复这个紧急bug。假设市区是一个无限大的区域,每条街道假设坐标是(X,Y),小易当前在(0,0)街道,办公室在(gx,gy)街道上。小易周围有多个出租车打车点,小易赶去办公室有两种选择,一种就是走路去公司,另外一种就是走到一个出租车打车点,然后从打车点的位置坐出租车去公司。每次移动到相邻的街道(横向或者纵向)走路将会花费walkTime时间,打车将花费taxiTime时间。小易需要尽快赶到公司去,现在小易想知道他最快需要花费多少时间去公司。

阅读全文 »

网易2017春招笔试——双核处理

发表于 2018-01-23 | 分类于 算法 , 2017网易春招笔试
字数统计: 1k | 阅读时长≈ 0:01

双核处理

题目

一种双核CPU的两个核能够同时的处理任务,现在有n个已知数据量的任务需要交给CPU处理,假设已知CPU的每个核1秒可以处理1kb,每个核同时只能处理一项任务。n个任务可以按照任意顺序放入CPU进行处理,现在需要设计一个方案让CPU处理完这批任务所需的时间最少,求这个最小的时间。

阅读全文 »

LeetCode 240. Search a 2D Matrix II

发表于 2018-01-12 | 分类于 算法 , LeetCode
字数统计: 1.1k | 阅读时长≈ 0:01

LeetCode 240. Search a 2D Matrix II

Description:

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:

  • Integers in each row are sorted in ascending from left to right.
  • Integers in each column are sorted in ascending from top to bottom.
    阅读全文 »

LeetCode 74. Search a 2D Matrix

发表于 2018-01-12 | 分类于 算法 , LeetCode
字数统计: 969 | 阅读时长≈ 0:01

LeetCode 74. Search a 2D Matrix

Description:

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:

  • Integers in each row are sorted from left to right.
  • The first integer of each row is greater than the last integer of the previous row.
    阅读全文 »

LeetCode 63. Unique Paths II

发表于 2018-01-12 | 分类于 算法 , LeetCode
字数统计: 1.3k | 阅读时长≈ 0:01

LeetCode 63. Unique Paths II

Description:

Follow up for “Unique Paths”:

Now consider if some obstacles are added to the grids. How many unique paths would there be?

An obstacle and empty space is marked as 1 and 0 respectively in the grid.

阅读全文 »

LeetCode 62. Unique Paths

发表于 2018-01-12 | 分类于 算法 , LeetCode
字数统计: 864 | 阅读时长≈ 0:01

LeetCode 62. Unique Paths

Description:

A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).

How many possible unique paths are there?

Note: m and n will be at most 100.

阅读全文 »

LeetCode 55. Jump Game

发表于 2018-01-12 | 分类于 算法 , LeetCode
字数统计: 851 | 阅读时长≈ 0:01

LeetCode 55. Jump Game

Description:

Given an array of non-negative integers, you are initially positioned at the first index of the array.

Each element in the array represents your maximum jump length at that position.

Determine if you are able to reach the last index.

阅读全文 »

算法期中练习——1006. 最长公共子串

发表于 2018-01-06 | 分类于 算法 , 2017算法期中考
字数统计: 1.9k | 阅读时长≈ 0:02

算法期中练习——1006. 最长公共子串

Description:

给定两个字符串x = x­1x­2…x­n和y = y­1y­2…ym, 请找出x和y的最长公共子串的长度,也就是求出一个最大的k,使得存在下标i和j有x­ix­i+1…x­i+k-1 = yjy­j+1…y­j+k-1.
x和y只含有小写字母,长度均在1和1000之间.

阅读全文 »

算法期中练习——1005. 最小和

发表于 2018-01-06 | 分类于 算法 , 2017算法期中考
字数统计: 1.8k | 阅读时长≈ 0:02

算法期中练习——1005. 最小和

Description:

从数列A[0], A[1], A[2], …, A[N-1]中选若干个数,要求对于每个i(0 <= i < N-1),A[i]和A[i+1]至少选一个数,求能选出的最小和.
1 <= N <= 100000, 1 <= A[i] <= 1000

阅读全文 »
1…456…11
linjiafengyang

linjiafengyang

Debug myself and debug the world!

106 日志
7 分类
3 标签
GitHub CSDN
© 2019 linjiafengyang | 394k | 6:34