ICode9

精准搜索请尝试: 精确搜索
  • # 华为机试:HJ77火车进站 与 HJ50四则运算2022-08-08 16:31:18

    华为机试 记录两个与栈相关的算法题,折腾了一下午 需要注意dfs前后对称的操作 利用栈结构去处理存在明显先后顺序的问题,比如四则运算等 HJ77 火车进站 栈+dfs回溯 #include<bits/stdc++.h> using namespace std; int N; vector<vector<int>> res; vector<int> path; void dfs(sta

  • 华为机试-HJ65 查找两个字符串a,b中的最长公共子串2022-07-14 21:37:29

    日常刷题记录,欢迎讨论交流。   牛客网题目链接:https://www.nowcoder.com/practice/181a1a71c7574266ad07f9739f791506   描述 查找两个字符串a,b中的最长公共子串。若有多个,输出在较短串中最先出现的那个。 注:子串的定义:将一个字符串删去前缀和后缀(也可以不删)形成的字符串。请

  • 机试练习(四)——一些算法相关面试知识点2022-07-14 19:03:33

    面试可能会问到的一些问题 1.选择排序法和冒泡排序法的区别 冒泡排序是比较相邻位置的两个数,而选择排序是按顺序比较,找最大值或者最小值; 冒泡排序每一轮比较后,位置不对都需要换位置,选择排序每一轮比较都只需要换一次位置; 冒泡排序是通过数去找位置,选择排序是给定位置去找数;

  • 华为机试-HJ68 成绩排序2022-07-14 10:03:03

    日常刷题记录,欢迎讨论交流。 目前暂时想到的一种偷懒解法,持续更新。   牛客网题目链接:https://www.nowcoder.com/practice/8e400fd9905747e4acc2aeed7240978b   描述 给定一些同学的信息(名字,成绩)序列,请你将他们的信息按照成绩从高到低或从低到高的排列,相同成绩 都按先录入排

  • 机试练习(三)——经典算法2022-07-07 13:05:36

    排序算法 1.冒泡排序 点击查看代码 #include <cstdio> #include <algorithm> using namespace std; const int MAXN = 50; int a[MAXN]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &

  • 华为机试-HJ64 MP3光标位置2022-07-04 19:00:39

    哒嗒~这是我博客的第一篇随笔,加油加油! 今天下午在牛客网刷oj题,想把学习记录保存起来方便后续学习,因此使用博客记录一下。 牛客网题目链接:https://www.nowcoder.com/practice/eaf5b886bd6645dd9cfb5406f3753e15   描述 MP3 Player因为屏幕较小,显示歌曲列表的时候每屏只能显示

  • 关于华为OD是否值得进的个人建议2022-07-02 13:34:40

    1.关于华为OD是否值得进:   个人建议:不值得考虑。 2.以下是博主准备进入华为OD的经历: 1)进入华为OD整体流程:   机试考试  --->  技术一面  --->   技术二面  --->  HR三面   --->  英语机试(四级425及以上不需要) --->   性格测试   --->  入职及其他 2)最终结

  • od机试第三题2022-06-28 02:01:33

    ■ 题目描述 【统计文本数量】 题目描述 有一个文件,包含以一定规则写作的文本,请统计文件中包含的文本数量。 规则如下: 1. 文本以”;”分隔,最后一条可以没有”;”,但空文本不能算语句,比如”COMMAND A; ;”只能算一条语句 注意,无字符/空白字符/制表符都算作”空”文本; 2. 文本可以跨

  • 2022华为机试题目2022-06-12 19:31:32

    1、取近似值  Java https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a?tpId=37&tqId=21230&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D1%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26ty

  • OD 机试 字符串字母出现统计排序2022-05-23 08:02:27

    import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 输入 String str = in.nextLine(); // if(s

  • 牛客华为机试HJ1002022-04-23 09:05:34

    原题传送门 1. 题目描述 2. Solution import sys def solve(n): a1 = 2 d = 3 print(a1 * n + n * (n - 1) * d // 2) for line in sys.stdin: n = int(line.strip()) solve(n)

  • 牛客华为机试HJ1012022-04-23 09:05:10

    原题传送门 1. 问题描述 2. Solution import sys while True: try: n = int(input().strip()) nums = list(map(int, input().strip().split())) # 0代表升序排序,1代表降序排序 # 1 -> True, 0 -> False rev = int(input().strip(

  • 牛客华为机试HJ1022022-04-23 09:04:51

    原题传送门 1. 题目描述 2. Solution import sys if sys.platform != "linux": sys.stdin = open("input/HJ102.txt") def solve(s): from collections import Counter, defaultdict res = Counter(s).most_common() cnt_group = defaultdict(

  • 牛客华为机试HJ1032022-04-23 09:04:24

    原题传送门 1. 问题描述 2. Solution 1、思路 2、代码实现 import sys if sys.platform != "linux": file_in = open("input/HJ103.txt") sys.stdin = file_in def solve(nums, n): dp = [1] * n for i in reversed(range(n)): # 4, 3, 2, 1, 0

  • 牛客华为机试HJ1052022-04-23 09:04:07

    原题传送门 1. 问题描述 2. Solution neg_cnt = 0 pos_sum = 0 pos_cnt = 0 while True: try: n = int(input().strip()) if n < 0: neg_cnt += 1 elif n > 0: pos_sum += n pos_cnt += 1 except:

  • 牛客华为机试HJ1062022-04-23 09:03:19

    原题传送门 1. 题目描述 2. Solution import sys for line in sys.stdin: s = line.strip() print(s[::-1])

  • 牛客华为机试HJ1072022-04-23 09:03:01

    原题传送门 1. 题目描述 2. Solution 1、思路分析 二分法 2、代码实现 import sys if sys.platform != "linux": sys.stdin = open("input/HJ107.txt") def solve(n): if n >= 0: if n < 1: lo, hi = 0, 1 else: lo,

  • 牛客华为机试HJ1082022-04-23 09:02:46

    原题传送门 1. 题目描述 2. Solution import sys if sys.platform != "linux": sys.stdin = open("input/HJ108.txt") def gcd(a, b): return a if b == 0 else gcd(b, a % b) def lcm(a, b): return a // gcd(a, b) * b for line in sys.stdi

  • 牛客华为机试HJ962022-04-23 08:31:27

    原题传送门 1. 问题描述 2. Solution import re import sys if sys.platform != "linux": sys.stdin = open("input/HJ96.txt") def solve1(s): print(re.sub(r'(\d+)', r'*\1*', s)) # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

  • 牛客华为机试HJ972022-04-23 08:31:06

    原题传送门 1. 题目描述 2. Solution import sys if sys.platform != "linux": file_in = open("input/HJ97.txt") sys.stdin = file_in while True: try: n = int(input().strip()) nums = list(map(int, input().strip().split()

  • 牛客华为机试HJ822022-04-22 07:35:58

    原题传送门 1. 题目描述 2. Solution 1、思路 设要拆解的真分数为\(\frac{A}{B}\),设 B除以A的商为C,余数为D。即: \(B=A \cdot C+D\)。等式两边同时除以A,可得 \(\frac{B}{A} = C + \frac{D}{A} < C + 1(\because D < A)\) , 易知C + 1是大于\(\frac{B}{A}\)的最小分数。将分式倒置

  • 牛客华为机试HJ832022-04-22 07:35:36

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 2、代码实现 import sys if sys.platform != "linux": file_in = open("input/HJ83.txt") sys.stdin = file_in """ 7 4 2 2 1 0 5 4 7 4 0 0 0 -1 -1 """ while True: tr

  • 牛客华为机试HJ842022-04-22 07:35:19

    原题传送门 1. 题目描述 2. Solution import sys def solve(s): cnt = 0 for c in s: if c.isupper(): cnt += 1 print(cnt) for line in sys.stdin: s = line.strip() solve(s)

  • 牛客华为机试HJ852022-04-22 07:34:58

    原题传送门 1. 问题描述 2. Solution 1: Brute Force 1、思路 两层循环遍历所有子串,判断是否为回文,保留最长的子串。 2、代码实现 import sys if sys.platform != "linux": file_in = open("input/HJ85.txt") sys.stdin = file_in def check(s, i, j): start = i

  • 牛客华为机试HJ862022-04-22 07:34:45

    原题传送门 1. 题目描述 2. Solution1 1、思路分析 把输入n转成bit字符串,然后用0切开,对剩余每一个只包含1的部分求长度并取长度最大值为最终结果。 2、代码实现 import sys if sys.platform != "linux": file_in = open("input/HJ86.txt") sys.stdin = file_in def so

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有