由买买提看人间百态

topics

全部话题 - 话题: mymap
1 (共1页)
u*d
发帖数: 149
1
来自主题: WaterWorld版 - google mymap上可以加label吗? (转载)
【 以下文字转载自 Travel 讨论区 】
发信人: usd (有话好好说), 信区: Travel
标 题: google mymap上可以加label吗?
发信站: BBS 未名空间站 (Tue May 4 18:28:09 2010, 美东)
如图:
两个蓝色的标记旁边
可以自己加label吗?
因为还有好多不同的景点
地图打印出来没有label的话各景点很不容易区分阿
H*********a
发帖数: 34
2
来自主题: JobHunting版 - 写的LRU通不过大数据,帮忙看看
用的list和unordered_map
----------------------------
谢谢提醒,改过之后,发现还是通不过
class LRUCache{
public:
int cap;
unordered_map mymap;
list mylist;
LRUCache(int capacity) {
cap = capacity;
}

int get(int key) {
unordered_map::iterator it = mymap.find(key);
if (it == mymap.end())
return -1;
else {
list::iterator it_list = mylist.begin();
while(*it_list != key) it_list++;
myl... 阅读全帖
B*******1
发帖数: 2454
3
来自主题: JobHunting版 - google scramble string O(n) 解法
My code
pass all the test on 1337 online judge.
bool isScrambleHelper(const string &s1, const string &s2, map string>, bool> &myMap)
{
pair key = make_pair(s1, s2);
if (myMap.count(key) != 0) return myMap[key];
bool result = false;
if (s1 == s2) {
result = true;
} else if (s1.size() != s2.size() ) {
result = false;
} else {
for (int i = 1; i < s1.size(); i++) {
if ((isScrambleHelper(s1.substr(0, i), s2.substr(... 阅读全帖
e*******i
发帖数: 56
4
来自主题: JobHunting版 - Facebook Phone Interview
#include
#include
#include
using namespace std;
void printEqProducts(int n)
{
typedef unordered_multimap > MyMap;
typedef unordered_map ProductMap;
MyMap resMap;
ProductMap proMap;
for(int i=1; i<=n;i++)
for(int j=1;j<=n;j++)
{
resMap.insert( MyMap::value_type(i*j, pair(i, j)) );
proMap.insert( pair(i*j,i*j) );
}
pair阅读全帖
e*******i
发帖数: 56
5
来自主题: JobHunting版 - Facebook Phone Interview
#include
#include
#include
using namespace std;
void printEqProducts(int n)
{
typedef unordered_multimap > MyMap;
typedef unordered_map ProductMap;
MyMap resMap;
ProductMap proMap;
for(int i=1; i<=n;i++)
for(int j=1;j<=n;j++)
{
resMap.insert( MyMap::value_type(i*j, pair(i, j)) );
proMap.insert( pair(i*j,i*j) );
}
pair阅读全帖
g***j
发帖数: 1275
6
来自主题: JobHunting版 - 大家帮忙看看这个4sum怎么就不对
基本思路就是,先把两个的和存起来,并且把相应的index pair存到对应的直的map里
面去。
然后再把所有的两个的和和target的差算出来,去map里面找,因为map里面同样保存了
签名的数字的index,所以,只要后面两个数的最小的index比已有的最大的index大的
时候,就能保证不重复了。
可惜small set 15个总有一个不过,而且,因为显示问题,看不到哪个不过。哪个大侠
帮我看看代码?
class Solution {
public:
vector > fourSum(vector &num, int target) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int n = num.size();
vector > results;
if(n <= 3) return results;
m... 阅读全帖
a***e
发帖数: 413
7
我再看了看 http://www.cplusplus.com/reference/unordered_map/unordered_map/unordered_map/
请问你怎么知道那个map不用先判断是否里面有key对应的val,直接就像你那么写?int
curr=++map[key];(我是说你那么写是对的,但我不知道哪里能找到可以那么用的说
明?)
key=0L;key+=x;key<<=32;key+=y;
//find x,then y;
int curr=++map[key];
localmax=max(curr,localmax);
不用先判断key是否存在,像下面myMap这样
int hor = points[j].x - points[i].x;
int ver = points[j].y - points[i].y;
... 阅读全帖
o*****l
发帖数: 539
8
来自主题: Linux版 - bash to implement Map>
请教大侠们一个问题, 谢谢!
Is it possible to use bash to implement a data structure like
Map> in Java?
I tried this(test.sh), which fails
$ ./test.sh
d1FileToScriptMap
./test.sh: line 27: ${${myMap}["entities.csv"]}: bad substitution
line 27 is "scriptfile=${${myMap}["entities.csv"]}"
========= test.sh ===============================
#!/bin/bash
dataSources=("d1" "d2")
declare -A dataSrcToScriptAssociateArrayMap
dataSrcToScriptAssociateArrayMap=(
["d1"]=d1FileToScriptMap
... 阅读全帖
o******3
发帖数: 91
9
来自主题: JobHunting版 - 面试F家让先做programming puzzle
我今天又写了一下
现在这个可以过所有数据集合了
方法还是BFS
区别的 这次我没有模拟stack
直接在Array上操作 这样程序更简单 写的可以快一点
#include
#include
#include
#include
#include
using namespace std;
struct step
{
int step1;
int step2;
step(int s1, int s2)
{
step1 = s1;
step2 = s2;
}
};
int main()
{
int N; int K;
cin>>N;
cin>>K;

vector IniArray;

int currpeg;
for(int i=1; i<=N; i++)
{
cin>>currpeg;
IniArray.push_back(c... 阅读全帖
g***j
发帖数: 1275
10
Given an array of strings, return all groups of strings that are anagrams.
Note: All inputs will be in lower-case.
上面大小测试集都过了,但是总感觉有问题,至少感觉很臃肿,请问我写的这个代码哪
可以改进一下?
int getHashcode(string s) {

int code = 2166136261U;

sort(s.begin(), s.end());

for(int i = 0 ; i < s.length(); i++) {
code = code ^ (s[i]);
code = code * 16777619;
}

return code;
}
class Solution {
public:
vector anagrams(vector &strs) {
// Start typing your ... 阅读全帖
f*********0
发帖数: 17
11
来自主题: JobHunting版 - fb 电面
map mymap;
bool compare(string A, string B) {
for (int i = 0; i < A.size(); ++i) {
A[i] = mymap[A[i]];
}
for (int i = 0; i < B.size(); ++i) {
B[i] = mymap[B[i]];
}
int n = min(A.size(), B.size());
for (int i = 0; i < n; ++i) {
if (A[i] != B[i]) return A[i] < B[i];
}
if (B.size()==n) return false;
else return true;
}
void sortString(vector words, string order) {
for (int i = 0; i < order.size(); ++i) {
mym... 阅读全帖
o******3
发帖数: 91
12
来自主题: JobHunting版 - 面试F家让先做programming puzzle
决定把题目跟我写的很挫的代码贴上来,有需要的同学可以来看。。。
代码可以过sample test
但是目前还不能过所有的Test
题目:
There are K pegs. Each peg can hold discs in decreasing order of radius when
looked from bottom to top of the peg. There are N discs which have radius 1
to N; Given the initial configuration of the pegs and the final
configuration of the pegs, output the moves required to transform from the
initial to final configuration. You are required to do the transformations
in minimal number of moves.
A move consists of picking the topm... 阅读全帖
o******3
发帖数: 91
13
来自主题: JobHunting版 - 面试F家让先做programming puzzle
决定把题目跟我写的很挫的代码贴上来,有需要的同学可以来看。。。
代码可以过sample test
但是目前还不能过所有的Test
题目:
There are K pegs. Each peg can hold discs in decreasing order of radius when
looked from bottom to top of the peg. There are N discs which have radius 1
to N; Given the initial configuration of the pegs and the final
configuration of the pegs, output the moves required to transform from the
initial to final configuration. You are required to do the transformations
in minimal number of moves.
A move consists of picking the topm... 阅读全帖
w********s
发帖数: 1570
14
#include "stdafx.h"
#include
#include
#include
#include
typedef std::map> MyMap;
MyMap m;
int repeat2(char* str)
{
for (int i = 0; i < strlen(str); ++i)
{
char c = str[i];
if (m.find(c) == m.end())
{
std::vector v;
v.push_back(i);
m[c] = v;
}
else
{
m[c].push_back(i);
}
}
int* count = new int[strlen(str)];
mems... 阅读全帖
w********s
发帖数: 1570
15
#include "stdafx.h"
#include
#include
#include
#include
typedef std::map> MyMap;
MyMap m;
int repeat2(char* str)
{
for (int i = 0; i < strlen(str); ++i)
{
char c = str[i];
if (m.find(c) == m.end())
{
std::vector v;
v.push_back(i);
m[c] = v;
}
else
{
m[c].push_back(i);
}
}
int* count = new int[strlen(str)];
mems... 阅读全帖
s******k
发帖数: 3716
16
来自主题: JobHunting版 - 被thank you的fb电面面经
手快不需要5分钟
int getNumDecode(const char *str)
{
char temp[3]; temp[1] = temp[2] = '\0';
if(strlen(str) == 0) return 1;
int num = 0;
temp[0] = str[0];
if(mymap[temp)>0) // we have 1 digit decode a letter
num += getNumDecode(str+1);
if(strlen(str)==1) return num;
temp[1] = str[1];
if(mymap[temp]>0) // we have 2 digits decode a letter
num += str+2;
return num;
}
e*******s
发帖数: 1979
17
Copy List with Random Pointer
A linked list is given such that each node contains an additional random
pointer which could point to any node in the list or null.
Return a deep copy of the list.
下面注释里面是别人写的能跑过的 上面的是我的 到现在都改得几乎一模一样了
可是还是超时
/**
* Definition for singly-linked list with a random pointer.
* struct RandomListNode {
* int label;
* RandomListNode *next, *random;
* RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
* };
*/
class Solution {

public:
RandomList... 阅读全帖
w*******s
发帖数: 96
18
来自主题: JobHunting版 - 写的LRU通不过大数据,帮忙看看
你的get函数成功查询后,应该把list中它的位置调整到最新?
int get(int key) {
unordered_map::iterator it = mymap.find(key);
if (it == mymap.end())
return -1;
else
return it->second;
}
n*******e
发帖数: 37
19
来自主题: JobHunting版 - fb 电面
compare() 是不是也能这样做?
bool compare(string &A, string &B) {
for (int i = 0; i < A.size() && i < B.size(); i++) {
// if equal, continue to the next char;
// if not equal, return true if A[i] is smaller
if (A[i] != B[i])
return (mymap[A[i]] < mymap[B[i]]);
}

// if reach the end of A, A is then smaller
return (i == A.size()) ? true : false;
}
a*******n
发帖数: 64
20
来自主题: JobHunting版 - 面试题:设计一个expired map class
题目大概是:设计一个类似于普通map的class,主要的不同是添加每个元素的时候,有
一个时间参数long type, 单位是ms。比如50000,如果50000ms passes,这个元素没有
被人为删除的话,它需要被自动删除。base class的定义myMap::add, myMap::erase都
是pure virtual function。
我当时给出的答案是用STL::map存储,然后用STL:unordred_map存储<
current_time+时间参数, a list of elements of 1st map>,系统时间前进的时候,
去第二个map里找到list删除第一个map里的element。答得很笼统,当时要求写具体的
code,不知道C++里涉及到系统时间的函数是啥。
h***r
发帖数: 726
21
来自主题: Apple版 - xcode for leopard BUG??? help.
I use tr1/unordered_map
if mymap is const unordered_map&
mymap.find("str1");
would say "discards qualifiers".
How to fix this?
It runs great on linux.
h***r
发帖数: 726
22
来自主题: Programming版 - xcode for leopard BUG??? help.
【 以下文字转载自 Apple 讨论区 】
发信人: haier (no nickname), 信区: Apple
标 题: xcode for leopard BUG??? help.
发信站: BBS 未名空间站 (Tue Dec 8 15:09:47 2009, 美东)
I use tr1/unordered_map
if mymap is const unordered_map&
mymap.find("str1");
would say "discards qualifiers".
How to fix this?
It runs great on linux.
d*****e
发帖数: 7368
23
change myMap to
map myMap;
d****u
发帖数: 8
24
来自主题: EE版 - Re: matlab作图问题
你可真会省标题, 一标题多问题.
用自己的colormap就行了. 要啥颜色就啥颜色, 要红就红, 要黑就黑, 自己设,
没有比这更爽的了.
T=
0 0 3 3 3
1 3 2 2 1
3 0 0 0 1
1 1 1 0 0
0 0 3 3 2
mymap =
0 0 0 deep black;
0.3500 0.3500 0.3500 deep gray;
0.5500 0.5500 0.5500 gray;
1.0000 1.0000 1.0000 white;
subimage(T/3);
colormap(mymap);
m*******n
发帖数: 859
25
可以用的,我都用了一个多月了。建议你把相关文件都拷到micro sd卡上,安全又方便
。拷好后 在tools->settings->mymaps里面就能看到2012.20的地图,选中即可。
我是3790T,如果你是其它型号有些文件可能用不上,不过放哪儿也没什么影响。

├─ASR
│ 01YOQ874.SRX
│ 01YOQ875.ASR

├─Map
│ gmapsup2.img
│ gmap3d.img

├─JCV
│ D3191020A.JCV

└─G2S
│ D2329060A.G2S
l*********8
发帖数: 4642
26
来自主题: JobHunting版 - 被thank you的fb电面面经
what is mymap?
s*****n
发帖数: 994
27
来自主题: JobHunting版 - 问个C++里面用hash table的问题
刚才google了一下unordered_map
http://www.cplusplus.com/reference/stl/unordered_map/operator[]
里面的这句话是什么语法?
for (auto& x: mymap) {

发帖数: 1
28
来自主题: JobHunting版 - 求Google实习选组介绍
lz正在申请google实习,上周收到邮件说已经进pool,等待team match。可是搜了一下
发现google team太多,相关资料太少,不知道有没有前辈们能介绍一下大致有哪几个
team比较好呢?
hr上周和我约了3个host准备这两天面,一个是ad formats team,一个是mymaps team
,还有一个说是不在Engineer部门下的,是在People Operations下的一个
confidential的project……不知道前辈们对这几个team有没有什么评价呢?先谢谢大
家了!
u*d
发帖数: 149
29
来自主题: Travel版 - google mymap上可以加label吗?
如图:
两个蓝色的标记旁边
可以自己加label吗?
因为还有好多不同的景点
地图打印出来没有label的话各景点很不容易区分阿
j*******g
发帖数: 5
30
我也刚刚学的,不对的地方大家指正。
首先,最简单地说MapReduce是一种编程模式。举个例子,程序员有两个表分别有100条
记录要对他们进行join查询。最简单的办法是使用数据库。现在假设我们不想用数据库
,那么程序员把程序编写成这样
myMap.java
1.读入表文件A,B
2.做一些ETL工作,比如去除你不需要的列
3.将A和B里面的join key找出来,假设叫做key
4.将A和B所有记录按照(key,value)的格式发出去。
(key,value one from A)
(key,value two from A)
.......................
(key,value n from A)
(key,value one from B)
(key,value two from B)
.......................
(key,value m from B)
一般是发送到标准输出。
紧接着,运行时环境就处理你的(key,value)pair。把同样key的发到一个机器上(应该
是reduce进程,现在假设一台
d*******n
发帖数: 524
31
The output of the following piece of simple code to test stl map is very
weird.
//-------------------code-----------------------------
#include
#include
using namespace std;
class A{
public:
class CompA{
public:
bool operator() (const A& lhs, const A& rhs) const {
return (lhs.index < rhs.index);
}
};
string str;
int index;
A(string s = "", int i = 0) : str(s), index(i) {}
};
int main(){
map myMap;
m
d****p
发帖数: 685
32
your compare function wrong.
each key in myMap is converted to a A object with index set to 0 and thus
totally disables the compareA.
change (lhs.index < rhs.index); to lhs.str < rhs.str will populate the map
with 3 elements but not sure it is what u want.
1 (共1页)