Python Coding Interview Python Advanced Jupyter Jupyter Notebook
转载 2020-09-02 09:43:00
132阅读
2评论
whiteboard & coding interview practice 白板 & 面试 & 编码练习
转载 2020-08-28 10:57:00
132阅读
The following are top 10 algorithms related topics for coding interviews. As understanding those concepts requires much more effort,re viewed fro
转载 2023-06-08 11:58:41
68阅读
Cracking the coding interview--Q2.4December 16The digits are stored ..
转载 2013-07-30 17:02:00
60阅读
2评论
题目原文:Implement an algorithm to find the nth to last element of a singly linked list.译文:实现一个算法从一个单链表中返回倒数第n个元素。解答这道题的考点在于我们怎么在一个单链表中找到倒数第n个元素? 由于是单链表,所以我们没办法从最后一个元素数起,然后数n个得到答案。 但这种最直观的思路显然是没错的,那我们有没有办法通过别的方式,从最后的元素数起数 n个来得到我们想要的答案呢。这个次序颠倒的思路可以让我们联想到一种数据结构:栈。我们如果遍历一遍单链表,将其中的元素压栈,然后再将元素一一出栈。那么, 第n个出栈的
转载 2013-07-30 14:45:00
54阅读
2评论
#include "stdafx.h"#include <algorithm>#define MAX_LENGTH 500void delDuplicate(char* pStr, int iStrlen){   int iLargeLabel = 0;   int iSmallLabel = 0;   int i0 = 0; &nbs
原创 2013-06-12 18:00:30
340阅读
#include <stdafx.h>#include <string.h>#include <stdio.h>#define MAXLEN 1024int main(){    char pStrInput[MAXLEN];    char *pStr1 = "%20";    /
原创 2013-06-12 18:54:32
418阅读
题目原文:Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?译文:一张图像表示成NxN的矩阵,图像中每个像素是4个字节,写一个函数把图像旋转90度。 你能原地进行操作吗?(即不开辟额外的存储空间)解答我们假设要将图像逆时针旋转90度,顺时针是一个道理。如果原图如下所示:1 2 3 4 5 6 7 8 9 10 11 12 1
转载 2013-07-15 16:28:00
56阅读
2评论
题目原文:Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not.FOLLOW UPWrite the test cases for this method.译文:设计算法并写出代码移除字符串中重复的字符,不能使用额外的缓存空间。注意: 可以使用额外的一
转载 2013-07-15 10:48:00
83阅读
2评论
题目原文:Write a method to decide if two strings are anagrams or not.译文:写一个函数判断两个字符串是否是变位词。解答变位词(anagrams)指的是组成两个单词的字符相同,但位置不同的单词。比如说, abbcd和abcdb就是一对变位词。该题目有两种做法:O(nlogn)的解法由于组成变位词的字符是一模一样的,所以按照字典序排序后,两个字符串也就相等了。 因此我们可以用O(nlogn)的时间去排序,然后用O(n)的时间比较它们是否相等即可。代码如下: public static boolean isAnagraml(Strin...
转载 2013-07-15 11:14:00
53阅读
2评论
题目原文:Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)译文:写代码翻转一个C风格的字符串。(C风格的意思是"abcd"需要用5个字符来表示,包含末尾的 结束字符)解答这道题如果就是要考察你有没有注意到C风格字符串最后的那个结束符,那我觉得还是像书 上写的那样,在代码中有所体现。代码如下:java:package cha1;public class A002
转载 2013-07-11 17:02:00
88阅读
2评论
#include <stdafx.h>#include <string.h>#include <stdio.h>bool CheckRotation(const char *pStr1, cosnt char *pStr2){    int iLen1 = strlen(pStr1);    int iLen2 = str
原创 2013-06-12 19:32:16
436阅读
题目原文:Write code to remove duplicates from an unsorted linked list.FOLLOW UPHow would you solve this problem if a temporary buffer is not allowed?译文:从一个未排序的链表中移除重复的项进一步地,如果不允许使用临时的缓存,你如何解决这个问题?解答如果可以使用额外的存储空间,我们就开一个数组来保存一个元素的出现情况。 对于这种情况,最好的解决方法当然是使用哈希表,但令人非常不爽的是C++标准里是没有 哈希表的(java里有)。网上有人用ext下的hash_
转载 2013-07-30 14:23:00
70阅读
2评论
题目原文:Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring ( i.e., “waterbottle” is a rotation of “erbottlewat”).译文:假设你有一个isSubstring函数,可以检测一个字符串是否是另一个字符串
转载 2013-07-15 17:20:00
80阅读
2评论
题目原文:Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.译文:写一个函数处理一个MxN的矩阵,如果矩阵中某个元素为0,那么把它所在的行和列都置为0.解答简单题。遍历一次矩阵,当遇到元素等于0时,记录下这个元素对应的行和列。 可以开一个行数组row和列数组col,当元素a[i][j]等于0时, 就把row[i]和col[j]置为true。第二次遍历矩阵时,当某个元素对应的行row[i] 或列col[j]被设置为true,说明该元素在需要
转载 2013-07-15 17:06:00
82阅读
2评论
Implement a job scheduler which takes in a function f and an integer n, and calls f after nmilliseconds
转载 2019-03-13 06:05:00
52阅读
2评论
Given a string, find the longest subsequence consisting of a single character. Example: longest("ABAACDDDBBA") should return {'D': 3}.
转载 2019-02-28 03:04:00
126阅读
2评论
Chapter 16 | Low Level 16.1 Explain the following terms: virtual memory, page fault, thrashing. SOLUTION Virtual memory is a computer system...
转载 2012-11-23 23:53:00
35阅读
2评论
给定一个序列,随机打乱这个序列,新产生的序列和任意一个序列产生的可能性是一样的,就是所谓的完美随机洗牌。 看下面的运行结果: 上面第一列是原数列,下面一行是新产生的打乱的数列。 基本思想:如果n-1个数是乱序的,我们可以使用一个随机数发生器,如C的rand(),那么产生一个数字代表数列下标,把这个下标和n下标的数值对换,那么就产生了n个乱序数。 问题是我们怎么得到n-1个乱序数? 这就是从底到顶
转载 2013-12-13 15:38:00
122阅读
2评论
7.1 Design the data structures for a generic deck of cards. Explain how you would subclass it to implement particular card games. SOLUTION Assume...
转载 2012-11-23 23:51:00
177阅读
2评论
  • 1
  • 2
  • 3
  • 4
  • 5