crontab 最小间隔_今天我间隔了:如何找到不在数组中的最小数字
crontab 最小间隔
by Marin Abernethy
通过Marin Abernethy
今天我间隔了:如何找到不在数组中的最小数字 (Today I Spaced: how to find the smallest number that is not in the array)
TIS在我的第一次技术采访中。 这是我学到的。 (TIS in my first technical interview. Here’s what I learned.)
Today I Spaced in my first technical interview, and could barely rememberhow to console.log()
let alone find an optimal solution.
今天,我在第一次技术面试中就离开了,几乎不记得如何console.log()
更不用说找到最佳解决方案了。
First, a one sentence summary of my software journey: for a couple of years after my BA, I worked for a small software consultancy as a full stack developer before getting my Masters in Software Engineering, which I finished this year.
首先,用一句话总结一下我的软件历程:在获得文学学士学位后的几年中,我在一家小型软件咨询公司担任全栈开发人员,然后获得了今年的软件工程硕士学位。
Woah, ok. Maybe that should have been two sentences. Point is, I used to feel confident in my engineering capabilities, but the pressure of interviews has caused that confidence to wane slightly.
好的,好的 也许应该是两个句子。 重点是,我以前对自己的工程能力充满信心,但是面试的压力使这种信心略有减弱。
I spaced in my first technical phone interview today while live coding, but Ihope my Today I Spaced (TIS) moment will turn into a Today I Learned (TIL) after a walkthrough of my interview. Here goes nothing…
我今天在进行现场编码时进行了第一次技术电话面试,但希望我的今天我间隔(TIS)的瞬间将在我的采访演练后变成今天的我学到的(TIL)。 这里什么都没有...
问题 (The problem)
The interviewer framed the question in the context of the product the company builds, but it boils down to this: Given an array of integers, write a function that finds the lowest integer that is not in the array.
面试官在公司生产的产品的上下文中提出了这个问题,但归结为:给定一个整数数组,编写一个函数来查找不在数组中的最低整数。
For example, given the array, [5, 2, 1, 4, 0, 2]
, the function should return 3
.
例如,给定数组[5, 2, 1, 4, 0, 2]
,该函数应返回3
。
Simple, right? Let the spacing commence.
简单吧? 让间隔开始。
我哪里做错了 (Where I went wrong)
Hmm where do I start? As soon as the interviewer finished explaining the question, internal panic ensued. I couldn’t think.
嗯,我从哪里开始? 面试官解释完该问题后,立即产生了内部恐慌。 我没想到
Inner monologue: THINK Marin, THINK. Why aren’t you even trying to think about the problem? Aha! Google always knows. Yo Google, tell me what to do… Oh, wait I am supposed to talk. All of the advice online says I should talk through my thought process. Ahhh ok ok ok. I can't read and talk at the same time. Fine, bye Google.
内心独白: 思索马林,思索。 您为什么甚至不考虑这个问题? 啊哈! Google一直都知道。 Google哟,告诉我该怎么做...哦,等等,我应该谈谈。 网上所有的建议都说我应该仔细考虑一下自己的想法。 啊,好,好,好。 我不能同时阅读和交谈。 很好,再见Google
Outer monologue: “Ummm, ah, well… let's see. Hmmm. Yeah so, hm.”
外面的独白 :“嗯,嗯...让我们看看。 嗯 是的,嗯。”
After a few minutes of hemming and hawing, plus a minute or two ofsilence, I came up with this solution (in JavaScript):
经过几分钟的折边和牵引,再沉默一两分钟,我想到了这个解决方案(使用JavaScript):
Remember how I said I couldn’t even recall how to console.log()
? Well, after completing my first attempt, I was confused when Coderpad ran my function and nothing appeared on the screen. The interviewer had to remind me that it was, indeed, compiling properly, I just needed to console.log()
if I wanted to see the output in the console. Doh. Cue face to palm.
还记得我怎么说我什至不记得如何console.log()
吗? 好吧,在完成第一次尝试之后,当Coderpad运行我的功能时,我很困惑,屏幕上什么也没有出现。 面试官不得不提醒我,的确是正确地编译,如果我想在控制台中查看输出, console.log()
需要console.log()
即可。 h 提示面对手掌。
So I updated it: console.log(count)
. And it returned the correct answer! Wahooo! …Can I go home now?
所以我更新了它: console.log(count)
。 它返回了正确的答案! 哇! …我现在可以回家吗?
“Alright, now what is the time complexity of this algorithm?” the interviewer asked. I had printed out a list of different complexities to help me if it came up. Turns out I can’t read when I am nervous.
“好的,现在这个算法的时间复杂度是多少?” 面试官问。 我打印出了各种复杂性的列表,以帮助我解决问题。 原来,当我紧张的时候我不会读书。
THINK, Marin. THINK. Well, my solution is just a single loop, right? Loop === Constant
was scribbled on my printout. So I said “Constant, O(n) time”, without giving it much more thought.
想想,马林。 认为。 好吧,我的解决方案只是一个循环,对吗? Loop === Constant
在我的打印输出上写有Loop === Constant
。 所以我说“常数,O(n)时间”,而没有多加思考。
WRONG. Yes, I did write one while
loop. However, I failed to recognize the JavaScript includes()
function as anything other than magic. When pushed on this point by the interviewer, I realized that includes()
is also iterating through the array each time. So really, its O(n²) time complexity. Cue face to palm round two.
错误 。 是的,我确实编写了一个while
循环。 但是,我无法将JavaScript includes()
函数识别为魔术以外的任何东西。 当面试官将这一点推到这一点时,我意识到includes()
每次也在遍历数组。 确实,它的O(n²)时间复杂度。 提示面对掌第二轮。
For one brief moment, the wheels started turning. What data structures have I been reading about? Linked List? Doesn’t seem helpful. Stack? Nah. HashTable? Aha!
片刻之间,车轮开始转动。 我一直在阅读什么数据结构? 链表? 似乎没有帮助。 堆栈? 没事 哈希表? 啊哈!
寻求解决方案 (Towards a Solution)
Attempt number two:
尝试第二:
So I figured I could map each integer in the array to their frequency. Upon review of this solution post-interview, I realized it is unnecessary to keep track of how many times an integer appeared in the array. We just need to know whether it appeared at all, so the boolean true
would have sufficed. Either way, this is O(n) time complexity.
所以我想可以将数组中的每个整数映射到它们的频率。 在面试后对该解决方案进行审查后,我意识到没有必要跟踪整数在数组中出现了多少次。 我们只需要知道它是否完全出现即可,因此布尔值true
就足够了。 无论哪种方式,这都是O(n)时间复杂度。
Due to the limited remaining time, the interviewer asked me how I would solve this with only arrays. Ding! I said, “you could sort the array, and then iterate through it until there is a missing number”. Here is what I meant by that:
由于剩余时间有限,面试官问我如何仅使用数组来解决此问题。 ing! 我说:“您可以对数组进行排序,然后对其进行迭代,直到缺少数字为止”。 这就是我的意思:
Looking back, I see that not only could I have given a clearer explanation, but I should also have discussed the tradeoffs between this and my hashmap solution. That is, because this solution is done in-place, the space complexity is O(1) which is superior to the hashmap solution with O(n). However, it is safe to assume the sorting algorithm is O(n log n) time complexity, which is less efficient than the previous solution.
回顾过去,我不仅可以给出更清晰的解释,而且还应该讨论此方法与我的哈希图解决方案之间的权衡。 也就是说,因为此解决方案是就地完成的 ,所以空间复杂度为O(1),优于具有O(n)的哈希图解决方案。 但是,可以安全地假设排序算法的时间复杂度为O(n log n),这比以前的解决方案效率低。
Sigh. More practice! More Interviews! Stay tuned.
感叹 。 多练! 更多面试! 敬请关注。
TL; DR (TL;DR)
My brain, given the choice of fight or flight, when faced with an intimidating technical interview, chose flight. Maybe with a little more practice, it will choose to fight next time.
面对激烈的技术面试时,考虑到战斗还是逃跑,我的大脑选择了逃跑。 也许再多练习一下,它将选择下次战斗。
Note to self:
注意自我:
- Talk through a solution before coding it up. This may help you discover a more efficient solution sooner (e.g. the interviewer can be more than a sounding board, they sometimes give hints)在编写解决方案之前先讨论一下解决方案。 这可以帮助您及早发现更有效的解决方案(例如,面试官可能不仅是一个共鸣板,有时还会提供提示)
- Yes, talking through your answer is important, but not to the detriment of your final solution. Take a beat to think, if necessary.是的,讨论您的答案很重要,但不会损害您的最终解决方案。 如有必要,请稍作思考。
- Internal JavaScript functions aren’t magic! They have time and space complexity too.内部JavaScript函数不是魔术! 它们也具有时间和空间复杂性。
翻译自: https://www.freecodecamp.org/news/tis-find-the-smallest-integer-that-is-not-in-the-array-80479cec15e4/
crontab 最小间隔
相关文章:

计算起点地址和终点地址的最短驾车距离和驾车时间
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 需求: 在一个excel的xlsx表格中有很多起点的地址和终点的地址,要批量计算两个地址之间的距离和驾车时间,按照百度地图的最短距离计算。最后把得出的行驶距离和驾车时…

jmeter测试工具
jmeter的下载: http://jmeter.apache.org/download_jmeter.cgi 1.打开链接选择 Binaries 下.zip下载 下载完后解压 2.然后再下载java中jdk, 配置java的环境变量 JAVA_HOME 和path JAVA_HOME值中加jdk的安装目录 path后面加;%JAVA_HOME%\bin; 3.在jmeter解压目录中…

余数定理_如何用Java实现余数定理
余数定理by Anuj Pahade由Anuj Pahade 如何用Java实现余数定理 (How to implement the Chinese Remainder Theorem in Java) This post assumes that you know what Chinese Remainder Theorem (CRT) is and focuses on its implementation in Java. If you don’t, I’d reco…

C#如何根据DataTable生成泛型List或者动态类型list
背景:在项目中,sql语句检索返回DataTable,然后根据检索结果做进一步的操作,本篇文章即是介绍如何将DataTable快速生成泛型List返回。 假设存在如下学生类: 1 public class student 2 { 3 public int I…

Easyui combobox下拉框默认选中第一项
var val $(#cc).combobox("getData");for (var item in val[0]) { if (item "groupName") { $(this).combobox("select", val[0][item]); }}转载于:https://www.cnblogs.com/AmbiguousMiao/p/7094589.html

js 获取当前时间 随记
微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 获取当前时间 new Date().toTimeString().split( )[0];console.log(dete, date) //dete 11:39:46

使用Typescript的巧妙React上下文技巧-不是Redux
by Bill Girten比尔吉尔滕(Bill Girten) 使用Typescript的巧妙React上下文技巧- 不是 Redux (Clever React context tricks using Typescript — not Redux) by Bill Girten, Martin Maza, and Alison Stuart由Bill Girten ,Martin Maza和Alison Stuart 撰写 TLDR…

vagrant 介绍,安装与使用
可以帮你统一团队成员的开发环境。如果你或者你的伙伴创建了一个Vagrantfile,那么你只需要执行vagrant up就行了,所有的软件都会安装并且配置好。团队成员可以通过相同的Vagrantfile来创建他们的开发环境,无论他们是在Linux, Mac OS X, 或者W…

HTML元素的基本特性
1,Disabled 特性: 1 //Disabled 设置元素不可用: 2 3 $(this).attr("disabled","disabled") 4 5 //移除push元素的diasble特性: 6 7 $("#push").removeAttr(disabled) 2,z-index 特性…

js base64 解码
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 解码函数 function base64_decode (input) { // 解码,配合decodeURIComponent使用var base64EncodeChars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/";…

esl8266开发之旅_从ESL老师到越南软件开发人员的旅程
esl8266开发之旅by alberto montalesi通过阿尔贝托蒙塔莱西 从ESL老师到越南软件开发人员的旅程 (My Journey from an ESL Teacher to Software Developer in Vietnam) 介绍 (Introduction) Hi, my name is Alberto, and this is the story of how I learned to code, wrote a…

洛谷P2429 制杖题 [2017年6月计划 数论10]
P2429 制杖题 题目描述 求不大于 m 的、 质因数集与给定质数集有交集的自然数之和。 输入输出格式 输入格式:第一行二个整数 n,m。 第二行 n 个整数,表示质数集内的元素 p[i]。 输出格式:一个整数,表示答案,…

微信小程序框架封装登录,网络请求等公共模块及调用示例
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 这个公共模块封装了session的获取,和fromId发送,showToast成功和失败的弹窗。 微信小程序公共通用模块 const util require(../utils/util.js);function init() {var that th…

安装centos后无法引导启动windows7的解决方法
在电脑Windows7系统上安装Centos7,安装后找不到Windows7引导菜单。 原因:因为CentOS 7已采用新式的grub2系统,所以需要进入/boot/grub2目录后使用vi编辑grub.cfg文件。 解决方法一:修改Centos 7的Grub2引导,添加Window…

git最佳实践_Git最佳实践如何为我节省大量的返工时间
git最佳实践by Hemal Patel通过赫马尔帕特尔 Git最佳实践如何为我节省大量的返工时间 (How Git best practices saved me hours of rework) Recently I was working on the task to upgrade a certificate for a NodeJS application. This was last touched two years ago for…

商品列表选择尺寸和颜色高亮,并且把选择的数据传递到下一个页面
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 需求:商品列表选择属性,给中的属性显示高亮,并且把选择的数据记录下来传递到下一个页面。 项目下载地址:点击去下载 效果图: 选择商品的属性…

Android studio 使用心得(三)—从Eclipse迁移到Android studio
断断续续的也算是把eclipse上的代码成功迁移到android studio上来了,现在,我同事继续用eclipse,我用android studio,svn上还是之前eclipse的项目,迁移成功后,我也能happy的开发了,两不误.直接来分享我捉摸的…

代码改变世界_改变世界,一次只写一行代码
代码改变世界People like to look at changing the world as a big task. I believe changing the world can be done in little steps.人们喜欢将改变世界视为一项艰巨的任务。 我相信,改变世界可以一步步完成。 The key is identifying a problem and taking a l…

14_传智播客iOS视频教程_instancetype
12312312转载于:https://www.cnblogs.com/ZHONGZHENHUA/p/7097094.html

HDU 1011-Starship Troopers(树形背包)
题意: 有n个洞,连接像一棵树,每个包含一定数量的怪和价值,给你m个士兵,每个士兵能打20个怪,杀完一个洞的怪可得该洞的价值才可继续打相连的下面的洞(每个士兵只能打一个洞)ÿ…

微信小程序自定义组件之Picker组件
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 需求: 通过JS条件判断,满足条件就弹出Picker给用户选择一个数组里面的数据。 有些朋友可能会有疑问: 1.为什么要使用自定义的Picker组件,不是有原生的组…

kotlin ++ --_顺便说一句-探索Kotlin代表团
kotlin --by Adam Arold亚当阿罗德(Adam Arold) 顺便说一句-探索Kotlin代表团 (By the way — exploring delegation in Kotlin) Kotlin has an interesting keyword, by, which can be used for delegation. There is a lot of confusion around it, so in this article we’…

网页制作之html基础学习3-css样式表
样式:CSS(Cascading Style Sheets,层叠样式表),作用是美化HTML网页。 在样式里面用 /* */ 进行注释。 1、样式表的基本概念 1.1、样式表分类 1、内联样式表 和html联合显示,控制精确,但是可重用性差&#…

Mac OS X 下查看和设置JAVA_HOME
原文链接 : http://blog.csdn.net/done58/article/details/51138057 1, 查看Java版本 打开Mac电脑,查看JAVA版本,打开终端Terminal,通过命令行查看笔者的java版本:: [html] view plaincopy bogon:~ donny$ java -vers…

微信小程序获取用户设备的信息
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 可以获取用户的手机型号,手机操作系统,微信版本,屏幕宽高等等。 Object wx.getSystemInfoSync() wx.getSystemInfo 的同步版本 返回值 Object res 属性类型说明最…

php 命令执行crud_如何使用原始JavaScript执行CRUD操作
php 命令执行crudby Zafar Saleem通过Zafar Saleem 如何使用原始JavaScript执行CRUD操作 (How to perform CRUD operations using vanilla JavaScript) Nowadays there are a number of JavaScript frameworks around such as React, Angular, Vue and so on. They all offer …

关于手机系统信息的总结
获取IMEI号: /*** 获取IMEI号* * Description:* param param activity* param return* return String*/public static String getIMEI(Activity activity) {TelephonyManager manager (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);return manage…

pat1011. World Cup Betting (20)
1011. World Cup Betting (20) 时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueWith the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing b…

如何清空定时器
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 看代码 var aaaa; //利用slice function truncate(arr) {return arr.slice(0, -1); } Page({data: {},onShow() {console.log(yyyyyyyyyyyyyyyyyyy)clearInterval(aaaa)aaaa setInterval(function () {…

如何解决JavaScript中的根查找
介绍 (Introduction) I’ve been wanting to write about this topic for a while now. I recently had the opportunity to work on simulating the GoalSeek functionality of Excel for a web application. I found the whole purpose of GoalSeek and how it works fascina…