Challenge - 5 Problems
String Structure Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of String Indexing in Go
What is the output of this Go code snippet that accesses characters in a string?
DSA Go
package main import "fmt" func main() { s := "GoLang" fmt.Println(s[0]) fmt.Println(string(s[0])) }
Attempts:
2 left
💡 Hint
Remember that indexing a string in Go returns a byte (number), not a character.
✗ Incorrect
In Go, accessing s[0] returns the byte value of the first character, which is 71 for 'G'. Converting it to string prints 'G'.
🧠 Conceptual
intermediateWhy Strings Are Considered Data Structures
Which reason best explains why strings are considered data structures and not just plain text?
Attempts:
2 left
💡 Hint
Think about what makes a data structure different from just raw data.
✗ Incorrect
Strings are data structures because they organize characters in a sequence, allowing operations like indexing and slicing.
🔧 Debug
advancedIdentify the Error in String Modification
What error will this Go code produce when trying to modify a string character?
DSA Go
package main import "fmt" func main() { s := "hello" s[0] = 'H' fmt.Println(s) }
Attempts:
2 left
💡 Hint
Consider if strings in Go can be changed after creation.
✗ Incorrect
Strings in Go are immutable, so you cannot assign a new value to an index.
🚀 Application
advancedUsing Strings as Data Structures for Counting Characters
What is the output of this Go program that counts character frequencies in a string?
DSA Go
package main import "fmt" func main() { s := "banana" freq := make(map[rune]int) for _, ch := range s { freq[ch]++ } fmt.Println(freq['a']) fmt.Println(freq['b']) fmt.Println(freq['n']) }
Attempts:
2 left
💡 Hint
Count how many times each character appears in "banana".
✗ Incorrect
The letter 'a' appears 3 times, 'b' once, and 'n' twice.
🧠 Conceptual
expertWhy Strings Are More Than Just Text in Memory
Which statement best explains why strings are considered complex data structures in programming languages like Go?
Attempts:
2 left
💡 Hint
Think about what extra information and capabilities strings have beyond raw text.
✗ Incorrect
Strings include encoding details, length info, and support many operations, making them complex data structures.
