Data Structures and Algorithms

muigai unaka

Lab

Lab

Today we are going to track the movement of smoke in a forest that has started catching on fire. We are given a 2-dimensional array that describes the shape of the forest and the starting point of the fire. At an index in the array can be either a "." to represent a tree or a "m" to represent a mountain. A tree can catch on fire and spread the smoke, a mountain cannot catch on fire. We would like to create a function that goes from the starting point of the fire and replaces any "." or tree with an "s" to signify smoke.

Lab

Given a Video Game and N to limit the amount of similar video games given back, create a function that returns an array of recommended Video Games

 

class VideoGame {
     String title;
     Array<VideoGame> similarVideoGames;
}

Lab

Given an array of strings, group anagrams together.

 

/**
Input: 
["eat", "tea", "tan", "ate", "nat", "bat"],
Output: 
[
	["ate","eat","tea"],
	["nat","tan"],
	["bat"]
]
*/

Lab

/**
 * You're given strings J representing the types of stones 
 * that are jewels, and S representing the stones you have. 
 * Each character in S is a type of stone you have. You want 
 * to know how many of the stones you have are also jewels.
 * 
 * The letters in J are guaranteed distinct, and all characters 
 * in J and S are letters. Letters are case sensitive, so "a" 
 * is considered a different type of stone from "A"
 **/
// Examples
Input: J = "aA", S = "aAAbbbb"
Output: 3
Input: J = "z", S = "ZZ"
Output: 0

Data Structures and Algorithms Lab

By Muigai Unaka

Data Structures and Algorithms Lab

  • 427