Today I learned an interesting algorithm for finding the majority element.
The Boyer-Moore majority algorithm is a popular algorithm for finding the majority element in a list of integers. The majority element in an array (or list) is an element that appears more than n/2 times where n is the size of the array.
Here's a simple way to describe the Boyer-Moore Voting Algorithm:
1. Start with an initial candidate and a counter set to 0.
2. Iterate over the list of numbers.
3. For the current number: If the counter is zero, set the current number as the candidate.
4. If the current number is the candidate, increment the counter. Otherwise, decrement the counter.
5. The candidate will be the majority number.
#dart #leetcode #tipoftheday #algorithm
The Boyer-Moore majority algorithm is a popular algorithm for finding the majority element in a list of integers. The majority element in an array (or list) is an element that appears more than n/2 times where n is the size of the array.
Here's a simple way to describe the Boyer-Moore Voting Algorithm:
1. Start with an initial candidate and a counter set to 0.
2. Iterate over the list of numbers.
3. For the current number: If the counter is zero, set the current number as the candidate.
4. If the current number is the candidate, increment the counter. Otherwise, decrement the counter.
5. The candidate will be the majority number.
#dart #leetcode #tipoftheday #algorithm
π8π€2
Mobile Tech
In the second part of advanced questions I will cover these themes: - Pattern matching - Immutability - Isolates, heap, isolate groups - GC - Errors & exceptions - differences and proper handling - What is a widget, different types - Inherited Widget, itsβ¦
The second section of the advanced questions is due to be completed tomorrow.
π5
The second part is coming!
https://lazebny.io/flutter-advanced-two/
https://lazebny.io/flutter-advanced-two/
Michael Lazebny
Advanced Flutter Interview: Part two
This is the second article in a big series on advanced questions. I feel like it will be a permanent section on my blog π. If you haven't read the first part, I'd recommend going there first. Subscribe to my telegram channel and LinkedIn to not to miss excitingβ¦
π4π₯3πΎ2
Media is too big
VIEW IN TELEGRAM
Implemented both theme scope and locale scope for Sizzle Starter
π₯6π5
If previous key in widget doesn't match the new one, then
Anonymous Quiz
55%
Element will become defunct and a new one will be created.
14%
Element will become inactive, inserted into the tree and reactivated.
32%
If widget runtimeType matches then element will be reused and accept the new configuration.
β€2
Choose themes you are interested in (Top 3 wins) [Advanced Questions]
Final Results
50%
Streams, transformers, rxDart and implementations
39%
Futures, types, zones, implementations
43%
How does the routing work? Navigator, routes, pages, hero animations
14%
Focus System, focus scope, nodes, actions, shortcuts
11%
Gestures: hit testing, fighting, recognizers
36%
Render Objects, custom painter, parent data, layout, composing, painting, intrinsics
39%
Flutter Architecture: layers, embedding, method channels
43%
BLoC pattern
25%
Vieport & Scrollable: slivers, list views, sliver protocol
46%
State restoration, buckets, serialization
Mobile Tech
Choose themes you are interested in (Top 3 wins) [Advanced Questions]
The results are:
1. Streams
2. Navigator
3. State restoration
1. Streams
2. Navigator
3. State restoration
π₯6
Should BLoC know anything about its consumers?
Anonymous Quiz
10%
Yes. It addresses their requirements and may have states such as ShowDialogState.
90%
No. Its duty is to do business logic and be consumer-agnostic.
π3π1
Navigator uses _ under the hood to show routes.
Anonymous Quiz
46%
Stack
22%
Overlay
17%
IndexedStack
14%
Custom implementation based on multi child render object
The next article will be about streams: how do they work under the hood, comprehensive analysis. Transformers, generators, subscriptions, listeners. Stream controllers and rxdart.
β€10
What does `external` keyword mean in Dart?
Anonymous Quiz
11%
Element can be loaded later (deferred)
89%
Used internally to mark element that has different implementations for platforms(e.g. VM or dart2js)
Many people follow the official Flutter channel, and there is a well-known rubric called Observable Flutter, which invites the most renowned contributors and open-source activists.
Recently, Dane Mackier, the author of Stacked, presented the library and I aim to provide an overview of his brainchild. My objective is to inform and increase awareness of the architecture and principles presented, rather than critique.
Read about it in my article. This should be interesting for folks who don't use stacked as well.
Recently, Dane Mackier, the author of Stacked, presented the library and I aim to provide an overview of his brainchild. My objective is to inform and increase awareness of the architecture and principles presented, rather than critique.
Read about it in my article. This should be interesting for folks who don't use stacked as well.
Michael Lazebny
Stacked Framework: Critique & Ways to Improve
Stacked
Many people follow the official Flutter channel, and there is a well-known rubric called Observable Flutter, which invites the most renowned contributors and open-source activists.
Recently, Dane Mackier, the author of Stacked, presented the libraryβ¦
Many people follow the official Flutter channel, and there is a well-known rubric called Observable Flutter, which invites the most renowned contributors and open-source activists.
Recently, Dane Mackier, the author of Stacked, presented the libraryβ¦
π₯4π3
Mobile Tech
Photo
What will this code emit?
Anonymous Quiz
43%
Data received: my data
48%
Bad state: Stream has already been listened to.
8%
Data received: my data Data received: my data
Updated ThemeScope for sizzle starter. Simplified structure to be more predictable, by introducing ThemeMode and saving only seed color to shared preferences (not entire scheme)
https://github.com/hawkkiller/sizzle_starter/pull/247
https://github.com/hawkkiller/sizzle_starter/pull/247
GitHub
Updated theme scope and related units by hawkkiller Β· Pull Request #247 Β· hawkkiller/sizzle_starter
Now [ColorScheme] is not stored in SharedPreferences
[AppTheme] holds only seedColor and type
Type from [AppTheme] is converted to [ThemeMode] and passed to [MaterialApp]
Implemented DAO for [Share...
[AppTheme] holds only seedColor and type
Type from [AppTheme] is converted to [ThemeMode] and passed to [MaterialApp]
Implemented DAO for [Share...
β€βπ₯6β€2
As human beings, we can only control a small part of things, and it is natural that there are some things beyond our control. Do your best if you can influence the outcome. Otherwise, don't worry about it.
π5
How to work with Clipboard in flutter?
There is a class Clipboard for these purposes in flutter:services.
It has two simple methods: setData and getData.
#tip #flutter #clipboard
There is a class Clipboard for these purposes in flutter:services.
It has two simple methods: setData and getData.
#tip #flutter #clipboard
π9