Skip to content

Instantly share code, notes, and snippets.

View rohankandwal's full-sized avatar

Rohan Kandwal rohankandwal

  • Bengaluru, Karnataka, India
View GitHub Profile
# DSA Question Bank
## Arrays, Hashing, Prefix/Suffix
1. Find the second largest element in one pass without extra space.
2. Find the k largest distinct elements without fully sorting the array.
3. Find the two numbers that appear once when every other number appears twice.
4. Find the majority element that appears more than n / 2 times.
5. Find all elements that appear more than n / 3 times.
6. Count inversions in an array.
@rohankandwal
rohankandwal / main.dart
Created April 29, 2023 20:59
File Upload using WebView on Android
/// Read details on https://theprogrammingway.com/flutter-file-upload-using-webview-on-android/
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:webview_flutter_android/webview_flutter_android.dart';
void main() {
runApp(const MyApp());
@rohankandwal
rohankandwal / analysis_options.yaml
Created March 10, 2022 09:40 — forked from crizant/analysis_options.yaml
Flutter linting rules
analyzer:
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
linter:
rules:
- always_declare_return_types
@rohankandwal
rohankandwal / Flutter: Webview loading URL
Last active August 14, 2024 11:24
Loading a url into the webview
final _webViewPlugin = FlutterWebviewPlugin();
@override
Widget build(BuildContext context) {
return WillPopScope(
child: WebviewScaffold(
url: "https://www.google.com",
withZoom: false,
withLocalStorage: true,
withJavascript: true,
@rohankandwal
rohankandwal / Flutter Image as ListView Separator
Created November 27, 2019 11:11
Showing widgets between ListView items in Flutter
@override
Widget build(BuildContext context) {
return ListView.separated(
padding: EdgeInsets.only(top: 8),
separatorBuilder: (context, index) => Icon(Icons.add),
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(list[index].title),
leading: Image.network(list[index].image_url),
subtitle: Text(list[index].subtitle),
@rohankandwal
rohankandwal / Flutter Seperated ListView
Created November 27, 2019 11:05
Adding divider to Flutter's ListView using a Separator
@override
Widget build(BuildContext context) {
return ListView.separated(
padding: EdgeInsets.only(top: 8),
separatorBuilder: (context, index) => Divider(
height: 2,
color: Colors.red,
),
itemBuilder: (BuildContext context, int index) {
return ListTile(
@rohankandwal
rohankandwal / Flutter ListView
Created November 27, 2019 10:48
Basic Flutter ListView implementation
@override
Widget build(BuildContext context) {
return ListView.builder(
itemBuilder: (context, index) {
return ListTile(
title: Text(list[index].title),
leading: Image.network(list[index].image_url),
subtitle: Text(list[index].subtitle),
);
},
@rohankandwal
rohankandwal / RxSchedulersOverrideRule.java
Created May 20, 2018 11:37
RxSchedulersOverrideRule - subscriptions always subscribeOn and observeOn Schedulers.trampoline().
package com.itcse.beerrecepies;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import java.util.concurrent.Callable;
import io.reactivex.Scheduler;
import io.reactivex.android.plugins.RxAndroidPlugins;
@rohankandwal
rohankandwal / AppModule.java
Created May 10, 2018 11:02
AppModule - Used to inject fragments, service, activities with other modules
@Module(includes = {
AndroidInjectionModule.class, RepositoryModule.class,
MySharedPreferencesModule.class
ViewModelModule.class, LocalRepositoryModule.class, MQTTModule.class
})
abstract class AppModule {
/*
* Singleton annotation isn't necessary since Application instance is unique but is here for
* convention. In general, providing Activity, Fragment, BroadcastReceiver, etc does not require
* them to be scoped since they are the components being injected and their instance is unique.
@rohankandwal
rohankandwal / ViewModelModule.java
Created May 10, 2018 10:59
ViewModelModule - Module to bind your ViewModels. We also bind our custom ViewModelFactory here.
@Module
public abstract class ViewModelModule {
@Binds
@IntoMap
@ViewModelKey(SplashScreenViewModel.class)
abstract ViewModel bindSplashScreenViewModel(final SplashScreenViewModel splashScreenViewModel);
@Binds
@IntoMap
@ViewModelKey(LoginActivityViewModel.class)