-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
438 lines (377 loc) · 12 KB
/
index.html
File metadata and controls
438 lines (377 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DSA Interview Questions</title>
<style>
body {
font-family: "Poppins", sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
line-height: 1.8;
color: #333;
background: linear-gradient(120deg, #000, #fff);
color: #eaeaea;
}
h1 {
text-align: center;
font-family: "Poppins", sans-serif;
color: #fff; /* Solid white color for the heading */
font-size: 2.5rem;
margin-bottom: 30px;
font-weight: 600;
}
#debug-info {
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.3);
padding: 15px;
margin-bottom: 20px;
white-space: pre-wrap;
word-break: break-word;
border-radius: 8px;
color: #d3d3d3;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
#search-container {
display: flex;
flex-wrap: wrap;
gap: 15px;
margin-bottom: 25px;
justify-content: space-between;
}
#search-input,
#company-filter,
#difficulty-filter {
padding: 12px;
flex: 1;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 8px;
font-size: 1rem;
background: rgba(0, 0, 0, 0.6);
color: #eaeaea;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
transition: all 0.3s ease-in-out;
}
#search-input:focus,
#company-filter:focus,
#difficulty-filter:focus {
border-color: #fff;
box-shadow: 0 4px 8px rgba(255, 255, 255, 0.3);
outline: none;
}
#questions-table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
background: linear-gradient(120deg, #000000, #444444);
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
animation: fadeIn 0.6s ease-in-out;
color: #eaeaea;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
#questions-table th,
#questions-table td {
border: 1px solid rgba(255, 255, 255, 0.2);
padding: 15px;
text-align: left;
font-size: 1rem;
}
#questions-table th {
background: linear-gradient(120deg, #1f1f1f, #555);
color: #fff;
text-transform: uppercase;
font-weight: bold;
letter-spacing: 0.5px;
}
#questions-table tbody tr:nth-child(even) {
background-color: rgba(255, 255, 255, 0.05);
}
#questions-table tbody tr:hover {
background-color: rgba(255, 255, 255, 0.1);
cursor: pointer;
transition: background-color 0.3s ease-in-out;
}
#questions-table td a {
text-decoration: none;
color: #fff;
font-weight: 500;
}
#questions-table td a:hover {
color: #f1f1f1;
text-decoration: underline;
}
#error-message {
color: #ff5252;
background: rgba(0, 0, 0, 0.7);
padding: 15px;
border: 1px solid rgba(255, 255, 255, 0.3);
margin-bottom: 20px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
font-size: 1rem;
}
/* Add subtle animations */
input,
select,
table,
th,
td {
transition: all 0.3s ease-in-out;
}
@media (max-width: 768px) {
#search-container {
flex-direction: column;
}
#search-input,
#company-filter,
#difficulty-filter {
font-size: 0.9rem;
padding: 10px;
}
#questions-table th,
#questions-table td {
font-size: 0.9rem;
padding: 10px;
}
}
@media (max-width: 480px) {
body {
padding: 10px;
}
h1 {
font-size: 1.8rem;
}
#search-input,
#company-filter,
#difficulty-filter {
font-size: 0.8rem;
padding: 8px;
}
}
</style>
</head>
<body>
<h1>Data Structures and Algorithms: Interview Guide</h1>
<div id="search-container">
<input type="text" id="search-input" placeholder="Search questions..." />
<select id="company-filter">
<option value="">All Companies</option>
</select>
<select id="difficulty-filter">
<option value="">All Difficulties</option>
<option value="Easy">Easy</option>
<option value="Medium">Medium</option>
<option value="Hard">Hard</option>
</select>
</div>
<table id="questions-table">
<thead>
<tr>
<th>LeetCode ID</th>
<th>Title</th>
<th>Acceptance</th>
<th>Difficulty</th>
<th>Frequency</th>
</tr>
</thead>
<tbody id="questions-body">
<!-- Questions will be dynamically populated here -->
</tbody>
</table>
<script>
// Global variables
let questionsData = [];
// Error display function
function displayError(message) {
const errorDiv = document.getElementById("error-message");
const debugDiv = document.getElementById("debug-info");
errorDiv.textContent = message;
debugDiv.textContent = message;
console.error(message);
}
// Robust CSV parsing function
function parseCSV(csvText) {
// Remove UTF-8 BOM
csvText = csvText.replace(/^\uFEFF/, "");
// Split lines, handling different line endings
const lines = csvText.trim().split(/\r\n|\n|\r/);
if (lines.length <= 1) {
displayError("No data found in the CSV");
return [];
}
// Extract headers
const headers = lines[0].split(",").map((header) => header.trim());
// Parse data rows
const data = [];
for (let i = 1; i < lines.length; i++) {
const line = lines[i];
// Skip empty lines
if (!line.trim()) continue;
try {
const values = parseCSVLine(line);
if (values.length >= headers.length) {
const rowData = {};
headers.forEach((header, index) => {
rowData[header] = (values[index] || "").trim();
});
data.push(rowData);
} else {
console.warn(
`Skipping line ${i + 1} due to incorrect number of fields`
);
}
} catch (error) {
console.error(`Error parsing line ${i + 1}:`, error);
}
}
return data;
}
// Advanced CSV line parsing
function parseCSVLine(line) {
const result = [];
let current = "";
let inQuotes = false;
for (let i = 0; i < line.length; i++) {
const char = line[i];
if (char === '"' && line[i + 1] === '"') {
current += '"';
i++;
} else if (char === '"') {
inQuotes = !inQuotes;
} else if (char === "," && !inQuotes) {
result.push(current);
current = "";
} else {
current += char;
}
}
result.push(current);
return result.map((field) => field.replace(/^"|"$/g, "").trim());
}
// Populate companies dropdown
function populateCompaniesDropdown(data) {
const companyFilter = document.getElementById("company-filter");
const allCompanies = new Set();
data.forEach((question) => {
const companies = (question["Company"] || "").split(",");
companies.forEach((company) => {
const trimmedCompany = company.trim();
if (trimmedCompany) {
allCompanies.add(trimmedCompany);
}
});
});
// Sort companies alphabetically
const sortedCompanies = Array.from(allCompanies).sort();
sortedCompanies.forEach((company) => {
const option = document.createElement("option");
option.value = company;
option.textContent = company;
companyFilter.appendChild(option);
});
}
// Render questions in the table
function renderQuestions(data) {
const questionsBody = document.getElementById("questions-body");
questionsBody.innerHTML = ""; // Clear existing rows
data.forEach((question) => {
const row = document.createElement("tr");
// Create LeetCode ID cell
const idCell = document.createElement("td");
idCell.textContent = question["ID"] || "";
// Create Title cell with LeetCode link
const titleCell = document.createElement("td");
const titleLink = document.createElement("a");
titleLink.href = question["Leetcode Question Link"] || "#";
titleLink.textContent = question["Title"] || "";
titleLink.target = "_blank";
titleCell.appendChild(titleLink);
// Create other cells
const cellContents = [
question["Acceptance"] || "",
question["Difficulty"] || "",
question["Frequency"] || "",
];
row.appendChild(idCell);
row.appendChild(titleCell);
cellContents.forEach((cellText) => {
const cell = document.createElement("td");
cell.textContent = cellText;
row.appendChild(cell);
});
questionsBody.appendChild(row);
});
}
// Filter questions
function filterQuestions() {
const searchInput = document
.getElementById("search-input")
.value.toLowerCase();
const companyFilter = document.getElementById("company-filter").value;
const difficultyFilter =
document.getElementById("difficulty-filter").value;
const filteredQuestions = questionsData.filter((question) => {
const matchesSearch =
searchInput === "" ||
(question["Title"] || "").toLowerCase().includes(searchInput) ||
(question["Company"] || "").toLowerCase().includes(searchInput);
const matchesCompany =
companyFilter === "" ||
(question["Company"] || "")
.split(",")
.map((c) => c.trim())
.includes(companyFilter);
const matchesDifficulty =
difficultyFilter === "" ||
question["Difficulty"] === difficultyFilter;
return matchesSearch && matchesCompany && matchesDifficulty;
});
renderQuestions(filteredQuestions);
}
// Load and process data
async function loadData() {
try {
// REPLACE THIS WITH YOUR ACTUAL CSV CONTENT
const response = await fetch("combined_output.csv");
const csvText = await response.text();
// Parse CSV
questionsData = parseCSV(csvText);
if (questionsData.length === 0) {
displayError("No questions found in the data");
return;
}
// Populate UI
populateCompaniesDropdown(questionsData);
renderQuestions(questionsData);
// Add event listeners for filtering
document
.getElementById("search-input")
.addEventListener("input", filterQuestions);
document
.getElementById("company-filter")
.addEventListener("change", filterQuestions);
document
.getElementById("difficulty-filter")
.addEventListener("change", filterQuestions);
} catch (error) {
displayError("Error processing CSV data: " + error.message);
}
}
// Load data when the page loads
document.addEventListener("DOMContentLoaded", loadData);
</script>
</body>
</html>