Lua Coding Practice

Solve Sort by Vowel Count using Lua Language

Solve Sort by Vowel Count using Lua to enhance your skills with lua coding practice , master coding concepts, and prepare for interviews with practical exercises and detailed solutions.

Sort by Vowel Count

Difficulty : Easy

Categories :

  • Sorting algorithms

Given a list of strings words, where each word consists of lowercase English letters, sort the list according to the following rules:

  • Primary sorting should be by the number of distinct vowels in the word (in ascending order)
  • If two words have the same number of distinct vowels, sort them lexicographically (normal dictionary order)

Note: The vowels are 'a', 'e', 'i', 'o', and 'u'.

Constraints:

  • 1 ≤ words.length ≤ 1000
  • 1 ≤ words[i].length ≤ 100
  • words[i] consists of only lowercase English letters

Examples:

Input: words = ["hello","world","leetcode"]
Output: ["world","hello","leetcode"]
Explanation:
"world" has 1 distinct vowel ('o')
"hello" has 2 distinct vowels ('e','o')
"leetcode" has 3 distinct vowels ('e','o','e')
Input: words = ["area","lead","eat"]
Output: ["eat","lead","area"]
Explanation:
All have 2 distinct vowels, so sort lexicographically

Problem Solving

Input

What You'll Find Here

Real-World Applications Solve problems inspired by Lua's common use cases, such as game development and embedded systems.

Step-by-Step Guidance Break down Lua's concepts into digestible lessons.

Practical Skills Build hands-on experience with Lua for real-world projects.

Choose from the following categories