Reverse Nodes in k-Group

Description

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

You may not alter the values in the nodes, only nodes itself may be changed.

Only constant memory is allowed.

For example,

Given this linked list: 1->2->3->4->5

For k = 2, you should return: 2->1->4->3->5

For k = 3, you should return: 3->2->1->4->5

Continue reading

Valid Parentheses

Description

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 "(]" and "([)]" are not.

给出包含三种括号的字符串,验证括号是否左右匹配

Continue reading

系统安装

系统: raspbian
工具(二选一):

  1. 将SD卡格式化成exFat格式
  2. 使用Etcher或者Win32DiskImager将下载的raspbian系统镜像(img文件)写入SD卡

写入完成之后就相当于系统安装完成了。这时候SD卡被分成两个区,有一个区是在windows下无法识别,不用理会。

这时候如果直接将SD卡插入树莓派,会发现“无法启动”。显示屏没信号,在路由器里找到树莓派的IP也无法用ssh登录。

我安装的时候就是踩到这个坑。以为安装失败,反复装了好几次,就差把SD卡写穿了。

Continue reading

4Sum

Description

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.

Note: The solution set must not contain duplicate quadruplets.

For example, given array S = [1, 0, -1, 0, -2, 2], and target = 0.

A solution set is:
[
  [-1,  0, 0, 1],
  [-2, -1, 1, 2],
  [-2,  0, 0, 2]
]

Continue reading

Author's picture

SelFree

城市永远年轻,而我们终将老去

Programer

ChengDu