Skip to content

Commit

Permalink
refactor: folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
thutasann committed Feb 25, 2025
1 parent f41502b commit a255485
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 4 deletions.
8 changes: 4 additions & 4 deletions data_structures/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Java Data Structures and Algorithms
# Java Data Structures and Algorithms and Javascript DeepDive

This section contains Data Structure and Algorithms in Java, Typescript and Frontend (Reactjs).

## Contents

- [Data Structures](./src/DataStructures)
- [Algorithms](./src/Algorithms)
- [NeetCode 150](./neetcode_150/)
- [Algorithms](./src/Algorithms/README.md)
- [NeetCode 150](./src/neetcode_150/README.md)
- [Javascript Questions](./js_questions)
- [Time and Space Complexity](./time_space_complexity/README.md)
- [Time and Space Complexity](./src/TimeSpaceComplexity/README.md)

**Patterns**

Expand Down
29 changes: 29 additions & 0 deletions data_structures/js_questions/concurrency/process_images.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const processImage = (image: string) => {
return new Promise<string>((resolve) => {
setTimeout(() => {
console.log(`Processes ${image}`);
resolve(image);
}, 1000);
});
};

async function ProcessImagesConcurrently(images: string[], maxConcurrent: number) {
const results: string[] = [];
const queue: Promise<number>[] = [];

for (let i = 0; i < images.length; i++) {
const currentImage = images[i];

const task = processImage(currentImage).then((result) => results.push(result));
queue.push(task);

if (queue.length >= maxConcurrent) {
await Promise.race(queue);
}
}

await Promise.all(queue);

console.log('all images processed : ', results);
}
ProcessImagesConcurrently(['image1', 'image2', 'image3', 'image4', 'image5'], 3);
1 change: 1 addition & 0 deletions data_structures/src/Algorithms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Algorithms
File renamed without changes.
File renamed without changes.

0 comments on commit a255485

Please sign in to comment.